45#include "llvm/ADT/STLExtras.h"
46#include "llvm/ADT/ScopeExit.h"
47#include "llvm/ADT/SmallString.h"
48#include "llvm/ADT/StringExtras.h"
49#include "llvm/Support/SaveAndRestore.h"
66class CheckDefaultArgumentVisitor
69 const Expr *DefaultArg;
72 CheckDefaultArgumentVisitor(
Sema &S,
const Expr *DefaultArg)
73 : S(S), DefaultArg(DefaultArg) {}
78 bool VisitLambdaExpr(
const LambdaExpr *Lambda);
83bool CheckDefaultArgumentVisitor::VisitExpr(
const Expr *
Node) {
84 bool IsInvalid =
false;
85 for (
const Stmt *SubStmt :
Node->children())
86 IsInvalid |= Visit(SubStmt);
93bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
const DeclRefExpr *DRE) {
96 if (!isa<VarDecl, BindingDecl>(
Decl))
99 if (
const auto *Param = dyn_cast<ParmVarDecl>(
Decl)) {
110 diag::err_param_default_argument_references_param)
112 }
else if (
auto *VD =
Decl->getPotentiallyDecomposedVarDecl()) {
127 diag::err_param_default_argument_references_local)
134bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
const CXXThisExpr *ThisE) {
139 diag::err_param_default_argument_references_this)
143bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
148 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E)) {
149 E = OVE->getSourceExpr();
150 assert(E &&
"pseudo-object binding without source expression?");
158bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
const LambdaExpr *Lambda) {
167 return S.
Diag(LC.getLocation(), diag::err_lambda_capture_default_arg);
170 Invalid |= Visit(D->getInit());
185 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
195 if (EST ==
EST_None && Method->hasAttr<NoThrowAttr>())
202 llvm_unreachable(
"should not see unresolved exception specs here");
231 "should not generate implicit declarations for dependent cases");
235 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
237 "Shouldn't collect exceptions when throw-all is guaranteed.");
241 if (ExceptionsSeen.insert(Self->Context.getCanonicalType(E)).second)
242 Exceptions.push_back(E);
270 if (Self->canThrow(S))
276 if (RequireCompleteType(Param->getLocation(), Param->getType(),
277 diag::err_typecheck_decl_incomplete_type))
292 if (Result.isInvalid())
294 Arg = Result.getAs<
Expr>();
296 CheckCompletedExpr(Arg, EqualLoc);
297 Arg = MaybeCreateExprWithCleanups(Arg);
305 Param->setDefaultArg(Arg);
309 UnparsedDefaultArgInstantiationsMap::iterator InstPos
310 = UnparsedDefaultArgInstantiations.find(Param);
311 if (InstPos != UnparsedDefaultArgInstantiations.end()) {
312 for (
unsigned I = 0,
N = InstPos->second.size(); I !=
N; ++I)
313 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
316 UnparsedDefaultArgInstantiations.erase(InstPos);
326 if (!param || !DefaultArg)
330 UnparsedDefaultArgLocs.erase(Param);
333 Param->setInvalidDecl();
335 EqualLoc, Param->getType().getNonReferenceType(),
VK_PRValue));
340 Diag(EqualLoc, diag::err_param_default_argument)
346 if (DiagnoseUnexpandedParameterPack(DefaultArg, UPPC_DefaultArgument)) {
353 if (Param->isParameterPack()) {
354 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
357 Param->setDefaultArg(
nullptr);
361 ExprResult Result = ConvertParamDefaultArgument(Param, DefaultArg, EqualLoc);
362 if (Result.isInvalid())
365 DefaultArg = Result.getAs<
Expr>();
368 CheckDefaultArgumentVisitor DefaultArgChecker(*
this, DefaultArg);
369 if (DefaultArgChecker.Visit(DefaultArg))
372 SetParamDefaultArgument(Param, DefaultArg, EqualLoc);
386 Param->setUnparsedDefaultArg();
387 UnparsedDefaultArgLocs[Param] = ArgLoc;
398 Param->setInvalidDecl();
399 UnparsedDefaultArgLocs.erase(Param);
401 EqualLoc, Param->getType().getNonReferenceType(),
VK_PRValue));
421 if (MightBeFunction) {
425 MightBeFunction =
false;
428 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
431 if (Param->hasUnparsedDefaultArg()) {
432 std::unique_ptr<CachedTokens> Toks =
435 if (Toks->size() > 1)
437 Toks->back().getLocation());
439 SR = UnparsedDefaultArgLocs[Param];
440 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
442 }
else if (Param->getDefaultArg()) {
443 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
444 << Param->getDefaultArg()->getSourceRange();
445 Param->setDefaultArg(
nullptr);
449 MightBeFunction =
false;
456 return P->hasDefaultArg() && !P->hasInheritedDefaultArg();
477 for (; PrevForDefaultArgs;
487 if (S && !isDeclInScope(PrevForDefaultArgs, ScopeDC, S) &&
525 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
528 p < NumParams; ++p) {
532 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
535 if (OldParamHasDfl && NewParamHasDfl) {
536 unsigned DiagDefaultParamID =
537 diag::err_param_default_argument_redefinition;
542 if (getLangOpts().MicrosoftExt) {
552 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
570 for (
auto Older = PrevForDefaultArgs;
572 Older = Older->getPreviousDecl();
573 OldParam = Older->getParamDecl(p);
578 }
else if (OldParamHasDfl) {
596 }
else if (NewParamHasDfl) {
600 diag::err_param_default_argument_template_redecl)
603 diag::note_template_prev_declaration)
634 if (Record->getDescribedClassTemplate())
636 else if (isa<ClassTemplatePartialSpecializationDecl>(Record))
643 diag::err_param_default_argument_member_template_redecl)
653 if (isa<CXXConstructorDecl>(New) &&
656 OldSM = getSpecialMember(cast<CXXMethodDecl>(Old));
657 if (NewSM != OldSM) {
660 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
695 if (isa<CXXDeductionGuideDecl>(New) &&
707 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
721 CheckForFunctionRedefinition(New, OldDefinition);
741 if (!TemplateParamLists.empty()) {
744 Diag(TemplateParamLists.front()->getTemplateLoc(),
745 diag::err_decomp_decl_template);
751 ? diag::ext_decomp_decl
752 : D.
getContext() == DeclaratorContext::Condition
753 ? diag::ext_decomp_decl_cond
754 : diag::warn_cxx14_compat_decomp_decl)
777 if (
auto SCS = DS.getStorageClassSpec()) {
780 CPlusPlus20SpecifierLocs.push_back(DS.getStorageClassSpecLoc());
783 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
786 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
788 CPlusPlus20SpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
790 if (DS.hasConstexprSpecifier()) {
791 BadSpecifiers.push_back(
793 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
795 if (DS.isInlineSpecified()) {
796 BadSpecifiers.push_back(
"inline");
797 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
800 if (!BadSpecifiers.empty()) {
801 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
802 Err << (
int)BadSpecifiers.size()
803 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
806 for (
auto Loc : BadSpecifierLocs)
808 }
else if (!CPlusPlus20Specifiers.empty()) {
809 auto &&Warn =
Diag(CPlusPlus20SpecifierLocs.front(),
811 ? diag::warn_cxx17_compat_decomp_decl_spec
812 : diag::ext_decomp_decl_spec);
813 Warn << (
int)CPlusPlus20Specifiers.size()
814 << llvm::join(CPlusPlus20Specifiers.begin(),
815 CPlusPlus20Specifiers.end(),
" ");
816 for (
auto Loc : CPlusPlus20SpecifierLocs)
828 Diag(DS.getVolatileSpecLoc(),
829 diag::warn_deprecated_volatile_structured_binding);
835 UPPC_DeclarationType))
849 ? diag::err_decomp_decl_parens
850 : diag::err_decomp_decl_type)
861 if (DS.isConstrainedAuto()) {
864 "No other template kind should be possible for a constrained auto");
882 ForVisibleRedeclaration);
888 Previous.getFoundDecl()->isTemplateParameter()) {
898 ? getShadowedDeclaration(BD,
Previous)
903 FilterLookupForScope(
Previous, DC, S, ConsiderLinkage,
907 auto *Old =
Previous.getRepresentativeDecl();
908 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
909 Diag(Old->getLocation(), diag::note_previous_definition);
911 CheckShadow(BD, ShadowedDecl,
Previous);
913 PushOnScopeChains(BD, S,
true);
915 ParsingInitForAutoVars.insert(BD);
923 ForVisibleRedeclaration);
926 bool AddToScope =
true;
928 ActOnVariableDeclarator(S, D, DC, TInfo,
Previous,
932 CurContext->addHiddenDecl(New);
935 if (isInOpenMPDeclareTargetContext())
936 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
945 if ((int64_t)
Bindings.size() != NumElems) {
946 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
959 E = GetInit(Loc, E.
get(), I++);
962 B->setBinding(ElemType, E.
get());
971 const llvm::APSInt &NumElems,
974 S,
Bindings, Src, DecompType, NumElems, ElemType,
1005 S,
Bindings, Src, DecompType, llvm::APSInt::get(2),
1009 return S.CreateBuiltinUnaryOp(Loc, I ? UO_Imag : UO_Real, Base);
1017 llvm::raw_svector_ostream OS(SS);
1024 TemplateParameterList::shouldIncludeTypeForArgument(
1029 return std::string(OS.str());
1036 auto DiagnoseMissing = [&] {
1046 return DiagnoseMissing();
1056 return DiagnoseMissing();
1057 if (Result.isAmbiguous())
1062 Result.suppressDiagnostics();
1064 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
1076 Loc, TraitTy, DiagID,
1083 assert(RD &&
"specialization of class template is not a class?");
1102namespace {
enum class IsTupleLike { TupleLike, NotTupleLike,
Error }; }
1105 llvm::APSInt &Size) {
1107 S, Sema::ExpressionEvaluationContext::ConstantEvaluated);
1120 return IsTupleLike::NotTupleLike;
1129 : R(R), Args(Args) {}
1132 return S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1136 } Diagnoser(R, Args);
1141 return IsTupleLike::Error;
1145 return IsTupleLike::Error;
1147 return IsTupleLike::TupleLike;
1162 S, R, Loc,
"tuple_element", Args,
1163 diag::err_decomp_decl_std_tuple_element_not_specialized))
1169 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1181struct InitializingBinding {
1190 ~InitializingBinding() {
1199 const llvm::APSInt &TupleSize) {
1200 if ((int64_t)
Bindings.size() != TupleSize) {
1201 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1217 bool UseMemberGet =
false;
1227 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1229 if (TPL->
size() != 0 &&
1230 isa<NonTypeTemplateParmDecl>(TPL->
getParam(0))) {
1232 UseMemberGet =
true;
1241 InitializingBinding InitContext(S, B);
1264 MemberGet, &Args,
nullptr);
1298 B->getDeclName().getAsIdentifierInfo(), RefType,
1302 RefVD->setImplicit();
1304 RefVD->setInlineSpecified();
1305 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1310 E = Seq.
Perform(S, Entity, Kind, Init);
1316 RefVD->setInit(E.
get());
1325 B->setBinding(T, E.
get());
1340 return Specifier->getType()->getAsCXXRecordDecl()->hasDirectFields();
1349 ClassWithFields = RD;
1361 for (
auto &
P : Paths) {
1365 BestPath->back().Base->getType())) {
1367 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1368 <<
false << RD << BestPath->back().Base->getType()
1369 <<
P.back().Base->getType();
1371 }
else if (
P.Access < BestPath->
Access) {
1377 QualType BaseType = BestPath->back().Base->getType();
1379 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1386 *BestPath, diag::err_decomp_decl_inaccessible_base);
1389 ClassWithFields = BaseType->getAsCXXRecordDecl();
1397 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1398 << (ClassWithFields == RD) << RD << ClassWithFields
1399 << Paths.front().back().Base->getType();
1410 diag::err_incomplete_type))
1422 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1423 unsigned NumFields = llvm::count_if(
1424 RD->
fields(), [](
FieldDecl *FD) { return !FD->isUnnamedBitfield(); });
1425 assert(
Bindings.size() != NumFields);
1426 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1436 for (
auto *FD : RD->
fields()) {
1437 if (FD->isUnnamedBitfield())
1442 if (!FD->getDeclName()) {
1449 if (FD->isAnonymousStructOrUnion()) {
1452 S.
Diag(FD->getLocation(), diag::note_declared_at);
1461 return DiagnoseBadNumberOfBindings();
1472 BasePair.
getAccess(), FD->getAccess())));
1495 if (FD->isMutable())
1501 return DiagnoseBadNumberOfBindings();
1543 llvm::APSInt TupleSize(32);
1545 case IsTupleLike::Error:
1549 case IsTupleLike::TupleLike:
1554 case IsTupleLike::NotTupleLike:
1563 << DD << !RD << DecompType;
1582 if (!getLangOpts().CXXExceptions)
1586 "Should only be called if types are otherwise the same.");
1597 NewType =
P->getPointeeType();
1610 if (CheckEquivalentExceptionSpec(
1630 if (FTD->isMemberSpecialization())
1636 if (Param->hasDefaultArg())
1647 if (!Param->hasDefaultArg() && !Param->isParameterPack() &&
1648 !(CurrentInstantiationScope &&
1649 CurrentInstantiationScope->isLocalPackExpansion(Param))) {
1650 if (Param->isInvalidDecl())
1652 else if (Param->getIdentifier())
1653 Diag(Param->getLocation(),
1654 diag::err_param_default_argument_missing_name)
1655 << Param->getIdentifier();
1657 Diag(Param->getLocation(),
1658 diag::err_param_default_argument_missing);
1666template <
typename... Ts>
1670 if (T->isDependentType())
1674 case Sema::CheckConstexprKind::Diagnose:
1676 std::forward<Ts>(DiagArgs)...);
1678 case Sema::CheckConstexprKind::CheckValid:
1679 return !T->isLiteralType(SemaRef.
Context);
1682 llvm_unreachable(
"unknown CheckConstexprKind");
1691 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
1695 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1699 SemaRef.
Diag(Loc, diag::note_constexpr_dtor_subobject)
1707 if (!Check(B.getBaseTypeLoc(), B.getType(),
nullptr))
1710 if (!Check(FD->getLocation(), FD->getType(), FD))
1720 unsigned ArgIndex = 0;
1723 e = FT->param_type_end();
1724 i != e; ++i, ++ArgIndex) {
1726 assert(PD &&
"null in a parameter list");
1729 diag::err_constexpr_non_literal_param, ArgIndex + 1,
1742 diag::err_constexpr_non_literal_return,
1755 case TTK_Struct:
return 0;
1756 case TTK_Interface:
return 1;
1757 case TTK_Class:
return 2;
1758 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1785 if (Kind == CheckConstexprKind::CheckValid)
1791 for (
const auto &I : RD->
vbases())
1792 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1793 << I.getSourceRange();
1798 if (!isa<CXXConstructorDecl>(NewFD)) {
1803 const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD);
1804 if (Method && Method->isVirtual()) {
1806 if (Kind == CheckConstexprKind::Diagnose)
1807 Diag(Method->getLocation(), diag::warn_cxx17_compat_constexpr_virtual);
1809 if (Kind == CheckConstexprKind::CheckValid)
1812 Method = Method->getCanonicalDecl();
1813 Diag(Method->getLocation(), diag::err_constexpr_virtual);
1820 if (WrittenVirtual != Method)
1822 diag::note_overridden_virtual_function);
1832 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(NewFD)) {
1836 if (!Dtor->getParent()->defaultedDestructorIsConstexpr()) {
1837 if (Kind == CheckConstexprKind::CheckValid)
1850 "CheckConstexprFunctionDefinition called on function with no body");
1865 for (
const auto *DclIt : DS->
decls()) {
1866 switch (DclIt->getKind()) {
1867 case Decl::StaticAssert:
1869 case Decl::UsingShadow:
1870 case Decl::UsingDirective:
1871 case Decl::UnresolvedUsingTypename:
1872 case Decl::UnresolvedUsingValue:
1873 case Decl::UsingEnum:
1881 case Decl::TypeAlias: {
1885 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1887 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1888 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1899 case Decl::CXXRecord:
1901 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition()) {
1902 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1905 ? diag::warn_cxx11_compat_constexpr_type_definition
1906 : diag::ext_constexpr_type_definition)
1914 case Decl::EnumConstant:
1915 case Decl::IndirectField:
1922 case Decl::Decomposition: {
1928 if (VD->isThisDeclarationADefinition()) {
1929 if (VD->isStaticLocal()) {
1930 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1931 SemaRef.
Diag(VD->getLocation(),
1933 ? diag::warn_cxx20_compat_constexpr_var
1934 : diag::ext_constexpr_static_var)
1941 if (SemaRef.
LangOpts.CPlusPlus23) {
1943 diag::warn_cxx20_compat_constexpr_var,
1944 isa<CXXConstructorDecl>(Dcl),
1947 SemaRef, Kind, VD->getLocation(), VD->getType(),
1948 diag::err_constexpr_local_var_non_literal_type,
1949 isa<CXXConstructorDecl>(Dcl))) {
1952 if (!VD->getType()->isDependentType() &&
1953 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1954 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1958 ? diag::warn_cxx17_compat_constexpr_local_var_no_init
1959 : diag::ext_constexpr_local_var_no_init)
1967 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1968 SemaRef.
Diag(VD->getLocation(),
1970 ? diag::warn_cxx11_compat_constexpr_local_var
1971 : diag::ext_constexpr_local_var)
1979 case Decl::NamespaceAlias:
1980 case Decl::Function:
1988 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1989 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2015 llvm::SmallSet<Decl*, 16> &Inits,
2019 if (Kind == Sema::CheckConstexprKind::CheckValid &&
2023 if (Field->isInvalidDecl())
2026 if (Field->isUnnamedBitfield())
2032 if (Field->isAnonymousStructOrUnion() &&
2033 (Field->getType()->isUnionType()
2034 ? !Field->getType()->getAsCXXRecordDecl()->hasVariantMembers()
2035 : Field->getType()->getAsCXXRecordDecl()->isEmpty()))
2038 if (!Inits.count(Field)) {
2039 if (Kind == Sema::CheckConstexprKind::Diagnose) {
2043 ? diag::warn_cxx17_compat_constexpr_ctor_missing_init
2044 : diag::ext_constexpr_ctor_missing_init);
2047 SemaRef.
Diag(Field->getLocation(),
2048 diag::note_constexpr_ctor_missing_init);
2052 }
else if (Field->isAnonymousStructOrUnion()) {
2053 const RecordDecl *RD = Field->getType()->castAs<RecordType>()->getDecl();
2054 for (
auto *I : RD->
fields())
2057 if (!RD->
isUnion() || Inits.count(I))
2074 switch (S->getStmtClass()) {
2075 case Stmt::NullStmtClass:
2079 case Stmt::DeclStmtClass:
2089 case Stmt::ReturnStmtClass:
2091 if (isa<CXXConstructorDecl>(Dcl)) {
2094 Cxx1yLoc = S->getBeginLoc();
2098 ReturnStmts.push_back(S->getBeginLoc());
2101 case Stmt::AttributedStmtClass:
2105 SemaRef, Dcl, cast<AttributedStmt>(S)->getSubStmt(), ReturnStmts,
2106 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind);
2108 case Stmt::CompoundStmtClass: {
2111 Cxx1yLoc = S->getBeginLoc();
2114 for (
auto *BodyIt : CompStmt->
body()) {
2116 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2122 case Stmt::IfStmtClass: {
2125 Cxx1yLoc = S->getBeginLoc();
2129 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2133 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2138 case Stmt::WhileStmtClass:
2139 case Stmt::DoStmtClass:
2140 case Stmt::ForStmtClass:
2141 case Stmt::CXXForRangeStmtClass:
2142 case Stmt::ContinueStmtClass:
2148 Cxx1yLoc = S->getBeginLoc();
2149 for (
Stmt *SubStmt : S->children()) {
2152 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2157 case Stmt::SwitchStmtClass:
2158 case Stmt::CaseStmtClass:
2159 case Stmt::DefaultStmtClass:
2160 case Stmt::BreakStmtClass:
2164 Cxx1yLoc = S->getBeginLoc();
2165 for (
Stmt *SubStmt : S->children()) {
2168 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2173 case Stmt::LabelStmtClass:
2174 case Stmt::GotoStmtClass:
2176 Cxx2bLoc = S->getBeginLoc();
2177 for (
Stmt *SubStmt : S->children()) {
2180 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2185 case Stmt::GCCAsmStmtClass:
2186 case Stmt::MSAsmStmtClass:
2188 case Stmt::CXXTryStmtClass:
2190 Cxx2aLoc = S->getBeginLoc();
2191 for (
Stmt *SubStmt : S->children()) {
2194 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2199 case Stmt::CXXCatchStmtClass:
2203 SemaRef, Dcl, cast<CXXCatchStmt>(S)->getHandlerBlock(), ReturnStmts,
2204 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2214 Cxx1yLoc = S->getBeginLoc();
2218 if (Kind == Sema::CheckConstexprKind::Diagnose) {
2219 SemaRef.
Diag(S->getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2235 if (isa<CXXTryStmt>(Body)) {
2249 case Sema::CheckConstexprKind::CheckValid:
2254 case Sema::CheckConstexprKind::Diagnose:
2257 ? diag::ext_constexpr_function_try_block_cxx20
2258 : diag::warn_cxx17_compat_constexpr_function_try_block)
2273 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2277 if (Kind == Sema::CheckConstexprKind::CheckValid) {
2284 }
else if (Cxx2bLoc.
isValid()) {
2285 SemaRef.
Diag(Cxx2bLoc,
2287 ? diag::warn_cxx20_compat_constexpr_body_invalid_stmt
2288 : diag::ext_constexpr_body_invalid_stmt_cxx23)
2290 }
else if (Cxx2aLoc.
isValid()) {
2291 SemaRef.
Diag(Cxx2aLoc,
2293 ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt
2294 : diag::ext_constexpr_body_invalid_stmt_cxx20)
2296 }
else if (Cxx1yLoc.
isValid()) {
2297 SemaRef.
Diag(Cxx1yLoc,
2299 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
2300 : diag::ext_constexpr_body_invalid_stmt)
2305 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2314 if (Constructor->getNumCtorInitializers() == 0 &&
2316 if (Kind == Sema::CheckConstexprKind::Diagnose) {
2320 ? diag::warn_cxx17_compat_constexpr_union_ctor_no_init
2321 : diag::ext_constexpr_union_ctor_no_init);
2326 }
else if (!Constructor->isDependentContext() &&
2327 !Constructor->isDelegatingConstructor()) {
2328 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2332 bool AnyAnonStructUnionMembers =
false;
2333 unsigned Fields = 0;
2335 E = RD->
field_end(); I != E; ++I, ++Fields) {
2336 if (I->isAnonymousStructOrUnion()) {
2337 AnyAnonStructUnionMembers =
true;
2345 if (AnyAnonStructUnionMembers ||
2346 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2350 llvm::SmallSet<Decl*, 16> Inits;
2351 for (
const auto *I: Constructor->inits()) {
2355 Inits.insert(ID->chain_begin(), ID->chain_end());
2358 bool Diagnosed =
false;
2359 for (
auto *I : RD->
fields())
2366 if (ReturnStmts.empty()) {
2375 case Sema::CheckConstexprKind::Diagnose:
2377 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2378 : diag::err_constexpr_body_no_return)
2384 case Sema::CheckConstexprKind::CheckValid:
2392 }
else if (ReturnStmts.size() > 1) {
2394 case Sema::CheckConstexprKind::Diagnose:
2398 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2399 : diag::ext_constexpr_body_multiple_return);
2400 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2401 SemaRef.
Diag(ReturnStmts[I],
2402 diag::note_constexpr_body_previous_return);
2405 case Sema::CheckConstexprKind::CheckValid:
2427 if (Kind == Sema::CheckConstexprKind::Diagnose &&
2430 diag::ext_constexpr_function_never_constant_expr)
2432 for (
size_t I = 0,
N = Diags.size(); I !=
N; ++I)
2433 SemaRef.
Diag(Diags[I].first, Diags[I].second);
2449 if (it != UndefinedButUsed.end()) {
2450 Diag(it->second, diag::err_immediate_function_used_before_definition)
2454 DiagnoseImmediateEscalatingReason(FD);
2463 "expected an immediate function");
2464 assert(FD->
hasBody() &&
"expected the function to have a body");
2465 struct ImmediateEscalatingExpressionsVisitor
2472 bool ImmediateFnIsConstructor;
2477 : SemaRef(SemaRef), ImmediateFn(FD),
2478 ImmediateFnIsConstructor(isa<CXXConstructorDecl>(FD)) {}
2480 bool shouldVisitImplicitCode()
const {
return true; }
2481 bool shouldVisitLambdaBody()
const {
return false; }
2486 if (CurrentConstructor && CurrentInit) {
2491 SemaRef.
Diag(Loc, diag::note_immediate_function_reason)
2492 << ImmediateFn << Fn << Fn->
isConsteval() << IsCall
2494 << (CurrentInit !=
nullptr)
2495 << (CurrentInit && !CurrentInit->
isWritten())
2496 << (CurrentInit ? CurrentInit->
getAnyMember() :
nullptr) << Range;
2498 bool TraverseCallExpr(
CallExpr *E) {
2499 if (
const auto *DR =
2501 DR && DR->isImmediateEscalating()) {
2507 if (!getDerived().TraverseStmt(A))
2514 if (
const auto *ReferencedFn = dyn_cast<FunctionDecl>(E->
getDecl());
2516 Diag(E, ReferencedFn,
false);
2534 return Base::TraverseConstructorInitializer(Init);
2539 return Base::TraverseCXXConstructorDecl(Ctr);
2542 bool TraverseType(
QualType T) {
return true; }
2543 bool VisitBlockExpr(
BlockExpr *T) {
return true; }
2545 } Visitor(*
this, FD);
2546 Visitor.TraverseDecl(FD);
2558 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2565 return dyn_cast_or_null<CXXRecordDecl>(DC);
2568 return dyn_cast_or_null<CXXRecordDecl>(CurContext);
2585 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2587 if (!getLangOpts().SpellChecking)
2593 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2595 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2613 Class = Class->getCanonicalDecl();
2615 for (
const auto &I : Current->bases()) {
2624 if (
Base->getCanonicalDecl() == Class)
2627 Queue.push_back(
Base);
2633 Current = Queue.pop_back_val();
2650 if (getLangOpts().
HLSL && Class->getTagKind() == TTK_Class &&
2655 if (BaseType->containsErrors()) {
2661 if (Class->isUnion()) {
2662 Diag(Class->getLocation(), diag::err_base_clause_on_union)
2669 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2676 if (BaseType->isDependentType()) {
2680 if (
CXXRecordDecl *BaseDecl = BaseType->getAsCXXRecordDecl()) {
2681 if (BaseDecl->getCanonicalDecl() == Class->getCanonicalDecl() ||
2682 ((BaseDecl = BaseDecl->getDefinition()) &&
2684 Diag(BaseLoc, diag::err_circular_inheritance)
2687 if (BaseDecl->getCanonicalDecl() != Class->getCanonicalDecl())
2688 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2701 if (!Class->getTypeForDecl()->isDependentType())
2702 Class->setInvalidDecl();
2704 Class->getTagKind() == TTK_Class,
2705 Access, TInfo, EllipsisLoc);
2709 if (!BaseType->isRecordType()) {
2710 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2716 if (BaseType->isUnionType()) {
2717 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2725 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2726 BaseType->getAsCXXRecordDecl())) {
2727 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
2736 if (RequireCompleteType(BaseLoc, BaseType,
2737 diag::err_incomplete_base_class, SpecifierRange)) {
2738 Class->setInvalidDecl();
2743 RecordDecl *BaseDecl = BaseType->castAs<RecordType>()->getDecl();
2744 assert(BaseDecl &&
"Record type has no declaration");
2746 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2748 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2753 const auto *BaseCSA = CXXBaseDecl->
getAttr<CodeSegAttr>();
2754 const auto *DerivedCSA = Class->getAttr<CodeSegAttr>();
2755 if ((DerivedCSA || BaseCSA) &&
2756 (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
2757 Diag(Class->getLocation(), diag::err_mismatched_code_seg_base);
2758 Diag(CXXBaseDecl->
getLocation(), diag::note_base_class_specified_here)
2770 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2778 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2779 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2781 << FA->isSpelledAsSealed();
2788 Class->setInvalidDecl();
2792 Class->getTagKind() == TTK_Class,
2793 Access, TInfo, EllipsisLoc);
2809 AdjustDeclIfTemplate(classdecl);
2815 Class->setIsParsingBaseSpecifiers();
2820 if (AL.isInvalid() || AL.getKind() == ParsedAttr::IgnoredAttribute)
2822 if (AL.getKind() == ParsedAttr::UnknownAttribute)
2823 Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
2824 << AL << AL.getRange();
2826 Diag(AL.getLoc(), diag::err_base_specifier_attribute)
2827 << AL << AL.isRegularKeywordAttribute() << AL.getRange();
2831 GetTypeFromParser(basetype, &TInfo);
2834 DiagnoseUnexpandedParameterPack(SpecifierRange.
getBegin(), TInfo,
2843 Class->setInvalidDecl();
2859 if (
auto Rec =
Type->
getAs<RecordType>()) {
2860 auto Decl = Rec->getAsCXXRecordDecl();
2863 for (
const auto &BaseSpec :
Decl->bases()) {
2866 if (Set.insert(
Base).second)
2884 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2891 unsigned NumGoodBases = 0;
2893 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2903 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2904 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2913 KnownBase = Bases[idx];
2914 Bases[NumGoodBases++] = Bases[idx];
2919 if (Bases.size() > 1)
2922 if (
const RecordType *Record = NewBaseType->
getAs<RecordType>()) {
2924 if (Class->isInterface() &&
2935 Class->addAttr(WeakAttr::CreateImplicit(Context));
2941 Class->setBases(Bases.data(), NumGoodBases);
2944 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2946 QualType BaseType = Bases[idx]->getType();
2950 if (BaseType->isDependentType())
2956 if (IndirectBaseTypes.count(CanonicalBase)) {
2960 = Class->isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2964 if (Paths.isAmbiguous(CanonicalBase))
2965 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
2966 << BaseType << getAmbiguousPathsDisplayString(Paths)
2967 << Bases[idx]->getSourceRange();
2969 assert(Bases[idx]->isVirtual());
2985 if (!ClassDecl || Bases.empty())
2988 AdjustDeclIfTemplate(ClassDecl);
2989 AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl), Bases);
3013 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
3034 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
3046 for (
unsigned I = Path.size(); I != 0; --I) {
3047 if (Path[I - 1].
Base->isVirtual()) {
3054 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
3061 assert(BasePathArray.empty() &&
"Base path array must be empty!");
3062 assert(Paths.isRecordingPaths() &&
"Must record paths!");
3063 return ::BuildBasePathArray(Paths.front(), BasePathArray);
3079 unsigned InaccessibleBaseID,
3080 unsigned AmbiguousBaseConvID,
3084 bool IgnoreAccess) {
3091 bool DerivationOkay = IsDerivedFrom(Loc, Derived,
Base, Paths);
3092 if (!DerivationOkay)
3097 Path = &Paths.front();
3102 if (!Path && getLangOpts().MSVCCompat) {
3104 if (PossiblePath.size() == 1) {
3105 Path = &PossiblePath;
3106 if (AmbiguousBaseConvID)
3107 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
3108 <<
Base << Derived << Range;
3115 if (!IgnoreAccess) {
3118 CheckBaseClassAccess(Loc,
Base, Derived, *Path, InaccessibleBaseID)) {
3134 if (AmbiguousBaseConvID) {
3142 Paths.setRecordingPaths(
true);
3143 bool StillOkay = IsDerivedFrom(Loc, Derived,
Base, Paths);
3144 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
3151 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3153 Diag(Loc, AmbiguousBaseConvID)
3154 << Derived <<
Base << PathDisplayStr << Range << Name;
3163 bool IgnoreAccess) {
3164 return CheckDerivedToBaseConversion(
3165 Derived,
Base, diag::err_upcast_to_inaccessible_base,
3166 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
3167 BasePath, IgnoreAccess);
3184 std::string PathDisplayStr;
3185 std::set<unsigned> DisplayedPaths;
3187 Path != Paths.end(); ++Path) {
3188 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
3191 PathDisplayStr +=
"\n ";
3193 for (CXXBasePath::const_iterator Element = Path->begin();
3194 Element != Path->end(); ++Element)
3195 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
3199 return PathDisplayStr;
3210 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
3213 CurContext->addHiddenDecl(ASDecl);
3214 return ProcessAccessDeclAttributeList(ASDecl, Attrs);
3238 FindHiddenVirtualMethods(MD, OverloadedMethods);
3240 if (!OverloadedMethods.empty()) {
3241 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3242 Diag(OA->getLocation(),
3243 diag::override_keyword_hides_virtual_member_function)
3244 <<
"override" << (OverloadedMethods.size() > 1);
3245 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3246 Diag(FA->getLocation(),
3247 diag::override_keyword_hides_virtual_member_function)
3248 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3249 << (OverloadedMethods.size() > 1);
3251 NoteHiddenVirtualMethods(MD, OverloadedMethods);
3260 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3261 Diag(OA->getLocation(),
3262 diag::override_keyword_only_allowed_on_virtual_member_functions)
3266 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3267 Diag(FA->getLocation(),
3268 diag::override_keyword_only_allowed_on_virtual_member_functions)
3269 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3281 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
3282 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
3295 if (getSourceManager().isMacroArgExpansion(Loc))
3296 SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).getBegin();
3297 SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
3298 if (SpellingLoc.
isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
3302 auto EmitDiag = [&](
unsigned DiagInconsistent,
unsigned DiagSuggest) {
3304 Inconsistent && !Diags.isIgnored(DiagInconsistent, MD->
getLocation())
3311 if (isa<CXXDestructorDecl>(MD))
3313 diag::warn_inconsistent_destructor_marked_not_override_overriding,
3314 diag::warn_suggest_destructor_marked_not_override_overriding);
3316 EmitDiag(diag::warn_inconsistent_function_marked_not_override_overriding,
3317 diag::warn_suggest_function_marked_not_override_overriding);
3326 FinalAttr *FA = Old->
getAttr<FinalAttr>();
3332 << FA->isSpelledAsSealed();
3341 return !RD->isCompleteDefinition() ||
3342 !RD->hasTrivialDefaultConstructor() ||
3343 !RD->hasTrivialDestructor();
3352 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
3356 std::map<CXXRecordDecl*, NamedDecl*> Bases;
3359 const auto Base = Specifier->getType()->getAsCXXRecordDecl();
3361 if (Bases.find(
Base) != Bases.end())
3363 for (
const auto Field :
Base->lookup(FieldName)) {
3364 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
3367 assert(Bases.find(
Base) == Bases.end());
3380 for (
const auto &
P : Paths) {
3381 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
3382 auto It = Bases.find(
Base);
3384 if (It == Bases.end())
3386 auto BaseField = It->second;
3387 assert(BaseField->getAccess() !=
AS_private);
3390 Diag(Loc, diag::warn_shadow_field)
3391 << FieldName << RD <<
Base << DeclIsField;
3392 Diag(BaseField->getLocation(), diag::note_shadow_field);
3414 if (Loc.isInvalid())
3417 Expr *BitWidth =
static_cast<Expr*
>(BW);
3419 assert(isa<CXXRecordDecl>(CurContext));
3426 if (cast<CXXRecordDecl>(CurContext)->isInterface()) {
3430 unsigned InvalidDecl;
3431 bool ShowDeclName =
true;
3441 else switch (Name.getNameKind()) {
3444 ShowDeclName =
false;
3449 ShowDeclName =
false;
3464 Diag(Loc, diag::err_invalid_member_in_interface)
3465 << (InvalidDecl-1) << Name;
3467 Diag(Loc, diag::err_invalid_member_in_interface)
3468 << (InvalidDecl-1) <<
"";
3494 diag::err_storageclass_invalid_for_member);
3514 const char *PrevSpec;
3519 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3523 const char *PrevSpec;
3529 "This is the only DeclSpec that should fail to be applied");
3533 isInstField =
false;
3543 if (!Name.isIdentifier()) {
3544 Diag(Loc, diag::err_bad_variable_name)
3553 if (TemplateParameterLists.size()) {
3555 if (TemplateParams->
size()) {
3564 diag::err_template_member_noparams)
3588 if (
DeclContext *DC = computeDeclContext(SS,
false))
3591 UnqualifiedIdKind::IK_TemplateId);
3599 if (MSPropertyAttr) {
3600 Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3601 BitWidth, InitStyle, AS, *MSPropertyAttr);
3604 isInstField =
false;
3606 Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3607 BitWidth, InitStyle, AS);
3612 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(CurContext));
3614 Member = HandleDeclarator(S, D, TemplateParameterLists);
3620 if (
Member->isInvalidDecl()) {
3622 }
else if (isa<VarDecl>(
Member) || isa<VarTemplateDecl>(
Member)) {
3625 Diag(Loc, diag::err_static_not_bitfield)
3627 }
else if (isa<TypedefDecl>(
Member)) {
3629 Diag(Loc, diag::err_typedef_not_bitfield)
3634 Diag(Loc, diag::err_not_integral_type_bitfield)
3635 << Name << cast<ValueDecl>(
Member)->getType()
3640 Member->setInvalidDecl();
3645 NonTemplateMember = FunTmpl->getTemplatedDecl();
3647 NonTemplateMember = VarTmpl->getTemplatedDecl();
3653 if (NonTemplateMember !=
Member)
3659 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3660 auto *TD = DG->getDeducedTemplate();
3663 if (AS != TD->getAccess() &&
3664 TD->getDeclContext()->getRedeclContext()->Equals(
3665 DG->getDeclContext()->getRedeclContext())) {
3666 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3667 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3670 for (
const auto *D : cast<CXXRecordDecl>(CurContext)->decls()) {
3671 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3672 LastAccessSpec = AccessSpec;
3674 assert(LastAccessSpec &&
"differing access with no access specifier");
3675 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3686 ? FinalAttr::Keyword_sealed
3687 : FinalAttr::Keyword_final));
3695 CheckOverrideControl(
Member);
3697 assert((Name || isInstField) &&
"No identifier for non-field ?");
3701 FieldCollector->Add(FD);
3703 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation())) {
3711 UnusedPrivateFields.insert(FD);
3719 class UninitializedFieldVisitor
3724 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3727 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3742 UninitializedFieldVisitor(
Sema &S,
3743 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3744 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3745 : Inherited(S.Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3746 Constructor(nullptr), InitList(
false), InitListFieldDecl(nullptr) {}
3749 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3750 bool CheckReferenceOnly) {
3752 bool ReferenceField =
false;
3757 Fields.push_back(FD);
3759 ReferenceField =
true;
3765 if (CheckReferenceOnly && !ReferenceField)
3771 for (
const FieldDecl *FD : llvm::drop_begin(llvm::reverse(Fields)))
3774 for (
auto UsedIter = UsedFieldIndex.begin(),
3775 UsedEnd = UsedFieldIndex.end(),
3776 OrigIter = InitFieldIndex.begin(),
3777 OrigEnd = InitFieldIndex.end();
3778 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3779 if (*UsedIter < *OrigIter)
3781 if (*UsedIter > *OrigIter)
3788 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3801 dyn_cast<MemberExpr>(
Base->IgnoreParenImpCasts())) {
3803 if (isa<VarDecl>(SubME->getMemberDecl()))
3806 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3811 AllPODFields =
false;
3813 Base = SubME->getBase();
3816 if (!isa<CXXThisExpr>(
Base->IgnoreParenImpCasts())) {
3821 if (AddressOf && AllPODFields)
3827 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3831 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3833 if (T->isPointerType() &&
3834 BaseClasses.count(T->getPointeeType())) {
3836 << T->getPointeeType() << FoundVD;
3841 if (!Decls.count(FoundVD))
3846 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3848 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3853 if (CheckReferenceOnly && !IsReference)
3857 unsigned diag = IsReference
3858 ? diag::warn_reference_field_is_uninit
3859 : diag::warn_field_is_uninit;
3863 diag::note_uninit_in_this_constructor)
3868 void HandleValue(
Expr *E,
bool AddressOf) {
3871 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3872 HandleMemberExpr(ME,
false ,
3878 Visit(CO->getCond());
3879 HandleValue(CO->getTrueExpr(), AddressOf);
3880 HandleValue(CO->getFalseExpr(), AddressOf);
3885 dyn_cast<BinaryConditionalOperator>(E)) {
3886 Visit(BCO->getCond());
3887 HandleValue(BCO->getFalseExpr(), AddressOf);
3892 HandleValue(OVE->getSourceExpr(), AddressOf);
3897 switch (BO->getOpcode()) {
3902 HandleValue(BO->getLHS(), AddressOf);
3903 Visit(BO->getRHS());
3906 Visit(BO->getLHS());
3907 HandleValue(BO->getRHS(), AddressOf);
3916 InitFieldIndex.push_back(0);
3917 for (
auto *Child : ILE->
children()) {
3918 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3919 CheckInitListExpr(SubList);
3923 ++InitFieldIndex.back();
3925 InitFieldIndex.pop_back();
3934 DeclsToRemove.clear();
3941 InitListFieldDecl =
Field;
3942 InitFieldIndex.clear();
3943 CheckInitListExpr(ILE);
3952 BaseClasses.erase(BaseClass->getCanonicalTypeInternal());
3957 HandleMemberExpr(ME,
true ,
false );
3966 Inherited::VisitImplicitCastExpr(E);
3972 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3976 if (ICE->getCastKind() == CK_NoOp)
3977 ArgExpr = ICE->getSubExpr();
3978 HandleValue(ArgExpr,
false );
3981 Inherited::VisitCXXConstructExpr(E);
3986 if (isa<MemberExpr>(Callee)) {
3987 HandleValue(Callee,
false );
3993 Inherited::VisitCXXMemberCallExpr(E);
3999 HandleValue(E->
getArg(0),
false);
4003 Inherited::VisitCallExpr(E);
4009 if (isa<UnresolvedLookupExpr>(Callee))
4010 return Inherited::VisitCXXOperatorCallExpr(E);
4014 HandleValue(Arg->IgnoreParenImpCasts(),
false );
4024 DeclsToRemove.push_back(FD);
4027 HandleValue(E->
getLHS(),
false );
4032 Inherited::VisitBinaryOperator(E);
4042 HandleValue(ME->
getBase(),
true );
4047 Inherited::VisitUnaryOperator(E);
4057 static void DiagnoseUninitializedFields(
4077 for (
auto *I : RD->
decls()) {
4078 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
4079 UninitializedFields.insert(FD);
4080 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
4081 UninitializedFields.insert(IFD->getAnonField());
4086 for (
const auto &I : RD->
bases())
4087 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
4089 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4092 UninitializedFieldVisitor UninitializedChecker(SemaRef,
4093 UninitializedFields,
4094 UninitializedBaseClasses);
4096 for (
const auto *FieldInit :
Constructor->inits()) {
4097 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
4100 Expr *InitExpr = FieldInit->getInit();
4105 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
4106 InitExpr =
Default->getExpr();
4110 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
4111 FieldInit->getAnyMember(),
4112 FieldInit->getBaseClass());
4114 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
4115 FieldInit->getAnyMember(),
4116 FieldInit->getBaseClass());
4128 PushFunctionScope();
4140 if (ParamDecl->getDeclName())
4141 PushOnScopeChains(ParamDecl, S,
false);
4146 return ActOnRequiresClause(ConstraintExpr);
4153 ConstraintExpr = CorrectDelayedTyposInExpr(ConstraintExpr);
4157 if (DiagnoseUnexpandedParameterPack(ConstraintExpr.
get(),
4158 UPPC_RequiresClause))
4161 return ConstraintExpr;
4176 return Seq.
Perform(*
this, Entity, Kind, InitExpr);
4186 PopFunctionScopeInfo(
nullptr, D);
4190 "must set init style when field is created");
4199 if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
4205 ExprResult Init = CorrectDelayedTyposInExpr(InitExpr,
nullptr,
4207 assert(Init.isUsable() &&
"Init should at least have a RecoveryExpr");
4209 Init = ConvertMemberDefaultInitExpression(FD, Init.get(), InitLoc);
4213 if (!Init.isInvalid())
4214 Init = ActOnFinishFullExpr(Init.get(),
false);
4215 if (Init.isInvalid()) {
4233 DirectBaseSpec =
nullptr;
4234 for (
const auto &
Base : ClassDecl->
bases()) {
4238 DirectBaseSpec = &
Base;
4246 VirtualBaseSpec =
nullptr;
4247 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
4256 Path != Paths.end(); ++Path) {
4257 if (Path->back().Base->isVirtual()) {
4258 VirtualBaseSpec = Path->back().Base;
4265 return DirectBaseSpec || VirtualBaseSpec;
4279 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
4280 DS, IdLoc, InitList,
4298 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
4299 DS, IdLoc, List, EllipsisLoc);
4308 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
4309 : ClassDecl(ClassDecl) {}
4311 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4314 return Member->getDeclContext()->getRedeclContext()->Equals(ClassDecl);
4320 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4321 return std::make_unique<MemInitializerValidatorCCC>(*
this);
4336 for (
auto *D : ClassDecl->
lookup(MemberOrBase))
4337 if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D))
4353 ExprResult Res = CorrectDelayedTyposInExpr(Init,
nullptr,
4362 AdjustDeclIfTemplate(ConstructorD);
4365 = dyn_cast<CXXConstructorDecl>(ConstructorD);
4389 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
4391 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
4393 <<
SourceRange(IdLoc, Init->getSourceRange().getEnd());
4395 return BuildMemberInitializer(
Member, Init, IdLoc);
4401 if (TemplateTypeTy) {
4402 BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
4403 if (BaseType.isNull())
4411 LookupResult R(*
this, MemberOrBase, IdLoc, LookupOrdinaryName);
4412 LookupParsedName(R, S, &SS);
4421 if (SS.
isSet() && isDependentScopeSpecifier(SS)) {
4422 bool NotUnknownSpecialization =
false;
4424 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
4425 NotUnknownSpecialization = !Record->hasAnyDependentBases();
4427 if (!NotUnknownSpecialization) {
4432 *MemberOrBase, IdLoc);
4433 if (BaseType.isNull())
4450 if (getLangOpts().MSVCCompat && !getLangOpts().
CPlusPlus20) {
4453 UnqualifiedBase->getInjectedClassNameSpecialization());
4455 for (
auto const &
Base : ClassDecl->
bases()) {
4457 Base.getType()->getAs<TemplateSpecializationType>();
4459 BaseTemplate->getTemplateName(), TN)) {
4460 Diag(IdLoc, diag::ext_unqualified_base_class)
4461 <<
SourceRange(IdLoc, Init->getSourceRange().getEnd());
4462 BaseType =
Base.getType();
4471 MemInitializerValidatorCCC CCC(ClassDecl);
4472 if (R.
empty() && BaseType.isNull() &&
4474 CCC, CTK_ErrorRecovery, ClassDecl))) {
4480 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4481 << MemberOrBase <<
true);
4482 return BuildMemberInitializer(
Member, Init, IdLoc);
4488 DirectBaseSpec, VirtualBaseSpec)) {
4493 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4494 << MemberOrBase <<
false,
4507 if (!TyD && BaseType.isNull()) {
4508 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
4509 << MemberOrBase <<
SourceRange(IdLoc,Init->getSourceRange().getEnd());
4514 if (BaseType.isNull()) {
4515 BaseType = getElaboratedType(ETK_None, SS, Context.
getTypeDeclType(TyD));
4516 MarkAnyDeclReferenced(TyD->
getLocation(), TyD,
false);
4528 return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc);
4536 assert((DirectMember || IndirectMember) &&
4537 "Member must be a FieldDecl or IndirectFieldDecl");
4539 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4542 if (
Member->isInvalidDecl())
4546 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4547 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4548 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
4549 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4557 if (
Member->getType()->isDependentType() || Init->isTypeDependent()) {
4560 DiscardCleanupsInEvaluationContext();
4562 bool InitList =
false;
4563 if (isa<InitListExpr>(Init)) {
4575 IdLoc, Init->getBeginLoc(), Init->getEndLoc())
4586 MemberInit = ActOnFinishFullExpr(MemberInit.
get(), InitRange.
getBegin(),
4593 Init = CreateRecoveryExpr(InitRange.
getBegin(), InitRange.
getEnd(), Args,
4599 Init = MemberInit.
get();
4618 if (!LangOpts.CPlusPlus11)
4619 return Diag(NameLoc, diag::err_delegating_ctor)
4621 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4623 bool InitList =
true;
4625 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4627 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4636 NameLoc, Init->getBeginLoc(), Init->getEndLoc())
4644 cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor()) &&
4645 "Delegating constructor with no target?");
4650 DelegationInit = ActOnFinishFullExpr(
4651 DelegationInit.
get(), InitRange.
getBegin(),
false);
4656 CreateRecoveryExpr(InitRange.
getBegin(), InitRange.
getEnd(), Args,
4668 if (CurContext->isDependentContext())
4669 DelegationInit = Init;
4683 if (!BaseType->isDependentType() && !BaseType->isRecordType())
4684 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4697 bool Dependent = CurContext->isDependentContext() &&
4698 (BaseType->isDependentType() || Init->isTypeDependent());
4703 if (!BaseType->containsUnexpandedParameterPack()) {
4704 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4711 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4714 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4724 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4733 if (!DirectBaseSpec && !VirtualBaseSpec) {
4742 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4749 DiscardCleanupsInEvaluationContext();
4754 InitRange.
getEnd(), EllipsisLoc);
4761 if (DirectBaseSpec && VirtualBaseSpec)
4762 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4767 BaseSpec = VirtualBaseSpec;
4770 bool InitList =
true;
4772 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4774 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4789 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin(),
4794 BaseInit = CreateRecoveryExpr(InitRange.
getBegin(), InitRange.
getEnd(),
4806 if (CurContext->isDependentContext())
4814 InitRange.
getEnd(), EllipsisLoc);
4824 TargetType, ExprLoc);
4844 bool IsInheritedVirtualBase,
4848 IsInheritedVirtualBase);
4852 switch (ImplicitInitKind) {
4858 BaseInit = InitSeq.
Perform(SemaRef, InitEntity, InitKind, std::nullopt);
4864 bool Moving = ImplicitInitKind ==
IIK_Move;
4865 ParmVarDecl *Param = Constructor->getParamDecl(0);
4866 QualType ParamType = Param->getType().getNonReferenceType();
4871 Constructor->getLocation(), ParamType,
4886 BasePath.push_back(BaseSpec);
4888 CK_UncheckedDerivedToBase,
4896 BaseInit = InitSeq.
Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4928 if (Field->isInvalidDecl())
4934 bool Moving = ImplicitInitKind ==
IIK_Move;
4935 ParmVarDecl *Param = Constructor->getParamDecl(0);
4936 QualType ParamType = Param->getType().getNonReferenceType();
4939 if (Field->isZeroLengthBitField(SemaRef.
Context))
4942 Expr *MemberExprBase =
4955 LookupResult MemberLookup(SemaRef, Field->getDeclName(), Loc,
4957 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4993 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
5008 "Unhandled implicit init kind!");
5024 InitSeq.
Perform(SemaRef, InitEntity, InitKind, std::nullopt);
5044 if (!Field->getParent()->isUnion()) {
5046 SemaRef.
Diag(Constructor->getLocation(),
5047 diag::err_uninitialized_member_in_ctor)
5048 << (
int)Constructor->isImplicit()
5050 << 0 << Field->getDeclName();
5051 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5056 SemaRef.
Diag(Constructor->getLocation(),
5057 diag::err_uninitialized_member_in_ctor)
5058 << (
int)Constructor->isImplicit()
5060 << 1 << Field->getDeclName();
5061 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
5078 CXXMemberInit =
nullptr;
5083struct BaseAndFieldInfo {
5086 bool AnyErrorsInInits;
5088 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
5090 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
5093 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
5105 bool isImplicitCopyOrMove()
const {
5116 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
5120 AllToInit.push_back(Init);
5123 if (Init->getInit()->HasSideEffects(S.
Context))
5129 bool isInactiveUnionMember(
FieldDecl *Field) {
5135 ActiveUnionMember.lookup(
Record->getCanonicalDecl()))
5136 return Active !=
Field->getCanonicalDecl();
5139 if (isImplicitCopyOrMove())
5144 if (
Field->hasInClassInitializer())
5148 if (!
Field->isAnonymousStructOrUnion())
5157 bool isWithinInactiveUnionMember(
FieldDecl *Field,
5160 return isInactiveUnionMember(Field);
5162 for (
auto *
C : Indirect->
chain()) {
5164 if (Field && isInactiveUnionMember(Field))
5175 if (T->isIncompleteArrayType())
5179 if (!ArrayT->getSize())
5182 T = ArrayT->getElementType();
5191 if (Field->isInvalidDecl())
5196 Info.AllBaseFields.lookup(Field->getCanonicalDecl()))
5197 return Info.addFieldInitializer(Init);
5211 if (Info.isWithinInactiveUnionMember(Field, Indirect))
5214 if (Field->hasInClassInitializer() && !Info.isImplicitCopyOrMove()) {
5232 return Info.addFieldInitializer(Init);
5242 if (Info.AnyErrorsInInits)
5253 return Info.addFieldInitializer(Init);
5260 Constructor->setNumCtorInitializers(1);
5264 Constructor->setCtorInitializers(initializer);
5267 MarkFunctionReferenced(
Initializer->getSourceLocation(), Dtor);
5268 DiagnoseUseOfDecl(Dtor,
Initializer->getSourceLocation());
5271 DelegatingCtorDecls.push_back(Constructor);
5273 DiagnoseUninitializedFields(*
this, Constructor);
5280 if (Constructor->isDependentContext()) {
5283 if (!Initializers.empty()) {
5284 Constructor->setNumCtorInitializers(Initializers.size());
5287 memcpy(baseOrMemberInitializers, Initializers.data(),
5289 Constructor->setCtorInitializers(baseOrMemberInitializers);
5294 Constructor->setInvalidDecl();
5299 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
5303 CXXRecordDecl *ClassDecl = Constructor->getParent()->getDefinition();
5307 bool HadError =
false;
5309 for (
unsigned i = 0; i < Initializers.size(); i++) {
5312 if (
Member->isBaseInitializer())
5313 Info.AllBaseFields[
Member->getBaseClass()->getAs<RecordType>()] =
Member;
5315 Info.AllBaseFields[
Member->getAnyMember()->getCanonicalDecl()] =
Member;
5318 for (
auto *
C : F->chain()) {
5321 Info.ActiveUnionMember.insert(std::make_pair(
5326 Info.ActiveUnionMember.insert(std::make_pair(
5334 for (
auto &I : ClassDecl->
bases()) {
5336 DirectVBases.insert(&I);
5340 for (
auto &VBase : ClassDecl->
vbases()) {
5342 = Info.AllBaseFields.lookup(VBase.getType()->getAs<RecordType>())) {
5350 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
5351 << VBase.getType() << ClassDecl;
5352 DiagnoseAbstractType(ClassDecl);
5355 Info.AllToInit.push_back(
Value);
5356 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
5361 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
5364 &VBase, IsInheritedVirtualBase,
5370 Info.AllToInit.push_back(CXXBaseInit);
5377 if (
Base.isVirtual())
5381 = Info.AllBaseFields.lookup(
Base.getType()->getAs<RecordType>())) {
5382 Info.AllToInit.push_back(
Value);
5383 }
else if (!AnyErrors) {
5392 Info.AllToInit.push_back(CXXBaseInit);
5397 for (
auto *Mem : ClassDecl->
decls()) {
5398 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
5403 if (F->isUnnamedBitfield())
5409 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
5418 if (Info.isImplicitCopyOrMove())
5421 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
5422 if (F->getType()->isIncompleteArrayType()) {
5424 "Incomplete array type is not valid");
5436 unsigned NumInitializers = Info.AllToInit.size();
5437 if (NumInitializers > 0) {
5438 Constructor->setNumCtorInitializers(NumInitializers);
5441 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
5443 Constructor->setCtorInitializers(baseOrMemberInitializers);
5447 MarkBaseAndMemberDestructorsReferenced(Constructor->getLocation(),
5448 Constructor->getParent());
5455 if (
const RecordType *RT = Field->getType()->getAs<RecordType>()) {
5458 for (
auto *Field : RD->
fields())
5463 IdealInits.push_back(Field->getCanonicalDecl());
5472 if (!
Member->isAnyMemberInitializer())
5475 return Member->getAnyMember()->getCanonicalDecl();
5481 if (
Previous->isAnyMemberInitializer())
5486 if (Current->isAnyMemberInitializer())
5487 Diag << 0 << Current->getAnyMember();
5489 Diag << 1 << Current->getTypeSourceInfo()->getType();
5495 if (Constructor->getDeclContext()->isDependentContext())
5500 bool ShouldCheckOrder =
false;
5501 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5503 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
5504 Init->getSourceLocation())) {
5505 ShouldCheckOrder =
true;
5509 if (!ShouldCheckOrder)
5520 for (
const auto &VBase : ClassDecl->
vbases())
5524 for (
const auto &
Base : ClassDecl->
bases()) {
5525 if (
Base.isVirtual())
5531 for (
auto *Field : ClassDecl->
fields()) {
5532 if (Field->isUnnamedBitfield())
5538 unsigned NumIdealInits = IdealInitKeys.size();
5539 unsigned IdealIndex = 0;
5548 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5553 for (; IdealIndex != NumIdealInits; ++IdealIndex)
5554 if (InitKey == IdealInitKeys[IdealIndex])
5560 if (IdealIndex == NumIdealInits && InitIndex) {
5561 WarnIndexes.push_back(InitIndex);
5564 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
5565 if (InitKey == IdealInitKeys[IdealIndex])
5568 assert(IdealIndex < NumIdealInits &&
5569 "initializer not found in initializer list");
5571 CorrelatedInitOrder.emplace_back(IdealIndex, InitIndex);
5574 if (WarnIndexes.empty())
5578 llvm::sort(CorrelatedInitOrder, llvm::less_first());
5584 Inits[WarnIndexes.front() - 1]->getSourceLocation(),
5585 WarnIndexes.size() == 1 ? diag::warn_initializer_out_of_order
5586 : diag::warn_some_initializers_out_of_order);
5588 for (
unsigned I = 0; I < CorrelatedInitOrder.size(); ++I) {
5589 if (CorrelatedInitOrder[I].second == I)
5595 Inits[I]->getSourceRange(),
5598 Inits[CorrelatedInitOrder[I].second]->getSourceRange()),
5604 if (WarnIndexes.size() == 1) {
5606 Inits[WarnIndexes.front()]);
5612 for (
unsigned WarnIndex : WarnIndexes) {
5615 diag::note_initializer_out_of_order);
5622bool CheckRedundantInit(
Sema &S,
5630 if (
FieldDecl *Field = Init->getAnyMember())
5631 S.
Diag(Init->getSourceLocation(),
5632 diag::err_multiple_mem_initialization)
5633 <<
Field->getDeclName()
5634 << Init->getSourceRange();
5636 const Type *BaseClass = Init->getBaseClass();
5637 assert(BaseClass &&
"neither field nor base");
5638 S.
Diag(Init->getSourceLocation(),
5639 diag::err_multiple_base_initialization)
5641 << Init->getSourceRange();
5649typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5650typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5652bool CheckRedundantUnionInit(
Sema &S,
5654 RedundantUnionMap &Unions) {
5659 while (
Parent->isAnonymousStructOrUnion() ||
Parent->isUnion()) {
5661 UnionEntry &En = Unions[
Parent];
5662 if (En.first && En.first != Child) {
5663 S.
Diag(Init->getSourceLocation(),
5664 diag::err_multiple_mem_union_initialization)
5665 <<
Field->getDeclName()
5666 << Init->getSourceRange();
5667 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5668 << 0 << En.second->getSourceRange();
5675 if (!
Parent->isAnonymousStructOrUnion())
5692 if (!ConstructorDecl)
5695 AdjustDeclIfTemplate(ConstructorDecl);
5698 = dyn_cast<CXXConstructorDecl>(ConstructorDecl);
5701 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5708 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5711 RedundantUnionMap MemberUnions;
5713 bool HadError =
false;
5714 for (
unsigned i = 0; i < MemInits.size(); i++) {
5718 Init->setSourceOrder(i);
5720 if (Init->isAnyMemberInitializer()) {
5722 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5723 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5725 }
else if (Init->isBaseInitializer()) {
5727 if (CheckRedundantInit(*
this, Init, Members[Key]))
5730 assert(Init->isDelegatingInitializer());
5732 if (MemInits.size() != 1) {
5733 Diag(Init->getSourceLocation(),
5734 diag::err_delegating_initializer_alone)
5735 << Init->getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5738 SetDelegatingInitializer(Constructor, MemInits[i]);
5749 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5751 DiagnoseUninitializedFields(*
this, Constructor);
5768 for (
auto *Field : ClassDecl->
fields()) {
5769 if (Field->isInvalidDecl())
5778 const RecordType* RT = FieldType->
getAs<RecordType>();
5795 CheckDestructorAccess(Field->getLocation(), Dtor,
5796 PDiag(diag::err_access_dtor_field)
5797 << Field->getDeclName()
5800 MarkFunctionReferenced(Location, Dtor);
5801 DiagnoseUseOfDecl(Dtor, Location);
5806 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5813 if (Dtor && Dtor->
isUsed())
5814 VisitVirtualBases =
false;
5820 for (
const auto &
Base : ClassDecl->
bases()) {
5821 const RecordType *RT =
Base.getType()->getAs<RecordType>();
5826 if (
Base.isVirtual()) {
5827 if (!VisitVirtualBases)
5829 DirectVirtualBases.insert(RT);
5845 CheckDestructorAccess(
Base.getBeginLoc(), Dtor,
5846 PDiag(diag::err_access_dtor_base)
5847 <<
Base.getType() <<
Base.getSourceRange(),
5850 MarkFunctionReferenced(Location, Dtor);
5851 DiagnoseUseOfDecl(Dtor, Location);
5854 if (VisitVirtualBases)
5855 MarkVirtualBaseDestructorsReferenced(Location, ClassDecl,
5856 &DirectVirtualBases);
5861 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases) {
5863 for (
const auto &VBase : ClassDecl->
vbases()) {
5865 const RecordType *RT = VBase.getType()->castAs<RecordType>();
5868 if (DirectVirtualBases && DirectVirtualBases->count(RT))
5882 if (CheckDestructorAccess(
5884 PDiag(diag::err_access_dtor_vbase)
5888 CheckDerivedToBaseConversion(
5890 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5894 MarkFunctionReferenced(Location, Dtor);
5895 DiagnoseUseOfDecl(Dtor, Location);
5904 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5905 SetCtorInitializers(Constructor,
false);
5906 DiagnoseUninitializedFields(*
this, Constructor);
5933 if (!isAbstractType(Loc, T))
5938 DiagnoseAbstractType(T->getAsCXXRecordDecl());
5945 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5951 if (Diags.isLastDiagnosticIgnored())
5961 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5962 MEnd = FinalOverriders.end();
5966 SOEnd = M->second.end();
5967 SO != SOEnd; ++SO) {
5974 if (SO->second.size() != 1)
5977 if (!SO->second.front().Method->isPure())
5980 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5983 Diag(SO->second.front().Method->getLocation(),
5984 diag::note_pure_virtual_function)
5985 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5989 if (!PureVirtualClassDiagSet)
5991 PureVirtualClassDiagSet->insert(RD);
5995struct AbstractUsageInfo {
6002 : S(S), Record(Record),
6003 AbstractType(S.Context.getCanonicalType(
6004 S.Context.getTypeDeclType(Record))),
6007 void DiagnoseAbstractType() {
6016struct CheckAbstractUsage {
6017 AbstractUsageInfo &Info;
6020 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
6021 : Info(Info), Ctx(Ctx) {}
6025#define ABSTRACT_TYPELOC(CLASS, PARENT)
6026#define TYPELOC(CLASS, PARENT) \
6027 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
6028#include "clang/AST/TypeLocNodes.def"
6034 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
6049 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
6059#define CheckPolymorphic(Type) \
6060 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
6061 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
6076 return Visit(
Next, Sel);
6084 if (T->isArrayType()) {
6089 if (CT != Info.AbstractType)
return;
6100 Info.DiagnoseAbstractType();
6106 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
6141 for (
auto *D : RD->
decls()) {
6142 if (D->isImplicit())
continue;
6145 if (
auto *FD = dyn_cast<FriendDecl>(D)) {
6146 D = FD->getFriendDecl();
6151 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
6153 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) {
6157 }
else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
6160 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
6162 }
else if (
auto *VTD = dyn_cast<VarTemplateDecl>(D)) {
6166 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6168 }
else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(D)) {
6179 assert(ClassAttr->
getKind() == attr::DLLExport);
6189 struct MarkingClassDllexported {
6200 ~MarkingClassDllexported() {
6203 } MarkingDllexportedContext(S, Class, ClassAttr->
getLocation());
6210 if (!
Member->hasAttr<DLLExportAttr>())
6215 auto *VD = dyn_cast<VarDecl>(
Member);
6216 if (VD && VD->getStorageClass() ==
SC_Static &&
6220 auto *MD = dyn_cast<CXXMethodDecl>(
Member);
6224 if (MD->isUserProvided()) {
6234 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6244 }
else if (MD->isExplicitlyDefaulted()) {
6253 }
else if (!MD->isTrivial() ||
6254 MD->isCopyAssignmentOperator() ||
6255 MD->isMoveAssignmentOperator()) {
6279 auto *CD = dyn_cast<CXXConstructorDecl>(
Member);
6280 if (!CD || !CD->isDefaultConstructor())
6282 auto *
Attr = CD->getAttr<DLLExportAttr>();
6288 if (!Class->isDependentContext()) {
6295 if (LastExportedDefaultCtor) {
6297 diag::err_attribute_dll_ambiguous_default_ctor)
6299 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
6300 << CD->getDeclName();
6303 LastExportedDefaultCtor = CD;
6309 bool ErrorReported =
false;
6310 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6314 S.
Diag(TD->getLocation(),
6315 diag::err_cuda_device_builtin_surftex_cls_template)
6317 ErrorReported =
true;
6322 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(Class);
6324 S.
Diag(Class->getLocation(),
6325 diag::err_cuda_device_builtin_surftex_ref_decl)
6327 S.
Diag(Class->getLocation(),
6328 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6332 TD = SD->getSpecializedTemplate();
6336 unsigned N = Params->
size();
6339 reportIllegalClassTemplate(S, TD);
6341 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6344 if (
N > 0 && !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
6345 reportIllegalClassTemplate(S, TD);
6347 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6351 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6352 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6353 reportIllegalClassTemplate(S, TD);
6355 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6363 bool ErrorReported =
false;
6364 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6368 S.
Diag(TD->getLocation(),
6369 diag::err_cuda_device_builtin_surftex_cls_template)
6371 ErrorReported =
true;
6376 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(Class);
6378 S.
Diag(Class->getLocation(),
6379 diag::err_cuda_device_builtin_surftex_ref_decl)
6381 S.
Diag(Class->getLocation(),
6382 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6386 TD = SD->getSpecializedTemplate();
6390 unsigned N = Params->
size();
6393 reportIllegalClassTemplate(S, TD);
6395 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6398 if (
N > 0 && !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
6399 reportIllegalClassTemplate(S, TD);
6401 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6405 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6406 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6407 reportIllegalClassTemplate(S, TD);
6409 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6414 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(2));
6415 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6416 reportIllegalClassTemplate(S, TD);
6418 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6426 for (
auto *Method : Class->methods()) {
6427 if (Method->isUserProvided())
6429 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
6440 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
6441 if (
Attr *TemplateAttr =
6442 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
6444 A->setInherited(
true);
6459 (!Class->isExternallyVisible() && Class->hasExternalFormalLinkage())) {
6460 Class->dropAttr<DLLExportAttr>();
6461 Class->dropAttr<DLLImportAttr>();
6465 if (!Class->isExternallyVisible()) {
6466 Diag(Class->getLocation(), diag::err_attribute_dll_not_extern)
6467 << Class << ClassAttr;
6475 if (!isa<VarDecl>(
Member) && !isa<CXXMethodDecl>(
Member))
6482 diag::err_attribute_dll_member_of_dll_class)
6483 << MemberAttr << ClassAttr;
6484 Diag(ClassAttr->getLocation(), diag::note_previous_attribute);
6485 Member->setInvalidDecl();
6489 if (Class->getDescribedClassTemplate())
6494 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
6499 const bool PropagatedImport =
6510 Class->dropAttr<DLLExportAttr>();
6515 ForceDeclarationOfImplicitMembers(Class);
6544 auto *Ctor = dyn_cast<CXXConstructorDecl>(MD);
6553 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->
isTrivial())
6560 if (VD && PropagatedImport)
6571 if (!getLangOpts().DllExportInlines && MD && MD->
isInlined() &&
6574 if (ClassExported) {
6575 NewAttr = ::new (getASTContext())
6576 DLLExportStaticLocalAttr(getASTContext(), *ClassAttr);
6578 NewAttr = ::new (getASTContext())
6579 DLLImportStaticLocalAttr(getASTContext(), *ClassAttr);
6586 Member->addAttr(NewAttr);
6596 "friend re-decl should not already have a DLLAttr");
6606 DelayedDllExportClasses.push_back(Class);
6628 NewAttr->setInherited(
true);
6629 BaseTemplateSpec->
addAttr(NewAttr);
6633 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
6634 ImportAttr->setPropagatedToBaseTemplate();
6640 checkClassLevelDLLAttribute(BaseTemplateSpec);
6655 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
6660 diag::note_template_class_explicit_specialization_was_here)
6661 << BaseTemplateSpec;
6664 diag::note_template_class_instantiation_was_here)
6665 << BaseTemplateSpec;
6678 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
6690 if (MD->isCopyAssignmentOperator())
6693 if (MD->isMoveAssignmentOperator())
6696 if (isa<CXXDestructorDecl>(FD))
6702 return DefaultedComparisonKind::Equal;
6704 case OO_ExclaimEqual:
6705 return DefaultedComparisonKind::NotEqual;
6711 return DefaultedComparisonKind::ThreeWay;
6716 case OO_GreaterEqual:
6720 return DefaultedComparisonKind::Relational;
6739 cast<CXXConstructorDecl>(FD));
6757 llvm_unreachable(
"Invalid special member.");
6775 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
6776 bool DtorIsTrivialForCall =
false;
6787 CopyCtorIsTrivial =
true;
6789 CopyCtorIsTrivialForCall =
true;
6793 if (CD->isCopyConstructor() && !CD->isDeleted() &&
6794 !CD->isIneligibleOrNotSelected()) {
6795 if (CD->isTrivial())
6796 CopyCtorIsTrivial =
true;
6797 if (CD->isTrivialForCall())
6798 CopyCtorIsTrivialForCall =
true;
6806 DtorIsTrivialForCall =
true;
6808 if (!DD->isDeleted() && DD->isTrivialForCall())
6809 DtorIsTrivialForCall =
true;
6813 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
6827 uint64_t TypeSize = isAArch64 ? 128 : 64;
6829 if (CopyCtorIsTrivial &&
6839 bool HasNonDeletedCopyOrMove =
false;
6845 HasNonDeletedCopyOrMove =
true;
6852 HasNonDeletedCopyOrMove =
true;
6860 if (MD->isDeleted() || MD->isIneligibleOrNotSelected())
6863 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6864 if (CD && CD->isCopyOrMoveConstructor())
6865 HasNonDeletedCopyOrMove =
true;
6866 else if (!isa<CXXDestructorDecl>(MD))
6869 if (!MD->isTrivialForCall())
6873 return HasNonDeletedCopyOrMove;
6884 bool IssuedDiagnostic =
false;
6887 if (!IssuedDiagnostic) {
6889 IssuedDiagnostic =
true;
6891 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
6894 return IssuedDiagnostic;
6908 if (Record->isAbstract() && !Record->isInvalidDecl()) {
6909 AbstractUsageInfo Info(*
this, Record);
6916 if (!Record->isInvalidDecl() && !Record->isDependentType() &&
6917 !Record->isAggregate() && !Record->hasUserDeclaredConstructor() &&
6918 !Record->isLambda()) {
6919 bool Complained =
false;
6920 for (
const auto *F : Record->fields()) {
6921 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
6924 if (F->getType()->isReferenceType() ||
6925 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6927 Diag(Record->getLocation(), diag::warn_no_constructor_for_refconst)
6928 << Record->getTagKind() << Record;
6932 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
6933 << F->getType()->isReferenceType()
6934 << F->getDeclName();
6939 if (Record->getIdentifier()) {
6952 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
6953 Record->hasUserDeclaredConstructor()) ||
6954 isa<IndirectFieldDecl>(D)) {
6955 Diag((*I)->getLocation(), diag::err_member_name_of_class)
6963 if (Record->isPolymorphic() && !Record->isDependentType()) {
6966 !Record->hasAttr<FinalAttr>())
6968 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
6971 if (Record->isAbstract()) {
6972 if (FinalAttr *FA = Record->getAttr<FinalAttr>()) {
6973 Diag(Record->getLocation(), diag::warn_abstract_final_class)
6974 << FA->isSpelledAsSealed();
6975 DiagnoseAbstractType(Record);
6980 if (!Record->hasAttr<FinalAttr>()) {
6982 if (
const FinalAttr *FA = dtor->getAttr<FinalAttr>()) {
6983 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
6984 << FA->isSpelledAsSealed()
6986 getLocForEndOfToken(Record->getLocation()),
6987 (FA->isSpelledAsSealed() ?
" sealed" :
" final"));
6988 Diag(Record->getLocation(),
6989 diag::note_final_dtor_non_final_class_silence)
6990 << Context.
getRecordType(Record) << FA->isSpelledAsSealed();
6996 if (Record->hasAttr<TrivialABIAttr>())
6997 checkIllFormedTrivialABIStruct(*Record);
7001 bool HasTrivialABI = Record->hasAttr<TrivialABIAttr>();
7004 Record->setHasTrivialSpecialMemberForCall();
7014 auto CheckCompletedMemberFunction = [&](
CXXMethodDecl *MD) {
7025 MD->
isDeleted() ? diag::err_deleted_override
7026 : diag::err_non_deleted_override,
7028 return MD->isDeleted() != V->isDeleted();
7032 DiagnoseDeletedDefaultedFunction(MD);
7040 : diag::err_non_consteval_override,
7042 return MD->isConsteval() != V->isConsteval();
7046 DiagnoseDeletedDefaultedFunction(MD);
7051 auto CheckForDefaultedFunction = [&](
FunctionDecl *FD) ->
bool {
7052 if (!FD || FD->
isInvalidDecl() || !FD->isExplicitlyDefaulted())
7056 if (DFK.
asComparison() == DefaultedComparisonKind::NotEqual ||
7057 DFK.
asComparison() == DefaultedComparisonKind::Relational) {
7058 DefaultedSecondaryComparisons.push_back(FD);
7062 CheckExplicitlyDefaultedFunction(S, FD);
7068 bool Incomplete = CheckForDefaultedFunction(M);
7071 if (Record->isDependentType())
7077 if (!M->isImplicit() && !M->isUserProvided()) {
7078 if (CSM != CXXInvalid) {
7079 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
7081 Record->finishedDefaultedOrDeletedMember(M);
7082 M->setTrivialForCall(
7084 SpecialMemberIsTrivial(M, CSM, TAH_ConsiderTrivialABI));
7085 Record->setTrivialForCallFlags(M);
7091 if ((CSM == CXXCopyConstructor || CSM == CXXMoveConstructor ||
7092 CSM == CXXDestructor) && M->isUserProvided()) {
7093 M->setTrivialForCall(HasTrivialABI);
7094 Record->setTrivialForCallFlags(M);
7097 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
7098 M->hasAttr<DLLExportAttr>()) {
7101 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
7102 CSM == CXXDestructor))
7103 M->dropAttr<DLLExportAttr>();
7105 if (M->hasAttr<DLLExportAttr>()) {
7107 DelayedDllExportMemberFunctions.push_back(M);
7114 if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
7115 M->isConstexpr() && M->size_overridden_methods())
7119 CheckCompletedMemberFunction(M);
7128 CompleteMemberFunction(Dtor);
7130 bool HasMethodWithOverrideControl =
false,
7131 HasOverridingMethodWithoutOverrideControl =
false;
7132 for (
auto *D : Record->decls()) {
7133 if (
auto *M = dyn_cast<CXXMethodDecl>(D)) {
7136 if (!Record->isDependentType()) {
7140 DiagnoseHiddenVirtualMethods(M);
7141 if (M->hasAttr<OverrideAttr>())
7142 HasMethodWithOverrideControl =
true;
7143 else if (M->size_overridden_methods() > 0)
7144 HasOverridingMethodWithoutOverrideControl =
true;
7147 if (!isa<CXXDestructorDecl>(M))
7148 CompleteMemberFunction(M);
7149 }
else if (
auto *F = dyn_cast<FriendDecl>(D)) {
7150 CheckForDefaultedFunction(
7151 dyn_cast_or_null<FunctionDecl>(F->getFriendDecl()));
7155 if (HasOverridingMethodWithoutOverrideControl) {
7156 bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
7157 for (
auto *M : Record->methods())
7158 DiagnoseAbsenceOfOverrideControl(M, HasInconsistentOverrideControl);
7162 for (
FunctionDecl *FD : DefaultedSecondaryComparisons) {
7163 CheckExplicitlyDefaultedFunction(S, FD);
7166 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD))
7167 CheckCompletedMemberFunction(MD);
7183 if (Record->isMsStruct(Context) && !Context.
getLangOpts().MSBitfields &&
7184 (Record->isPolymorphic() || Record->getNumBases())) {
7185 Diag(Record->getLocation(), diag::warn_cxx_ms_struct);
7188 checkClassLevelDLLAttribute(Record);
7189 checkClassLevelCodeSegAttribute(Record);
7191 bool ClangABICompat4 =
7192 Context.
getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver4;
7200 Record->setArgPassingRestrictions(CanPass
7209 Record->setParamDestroyedInCallee(
true);
7210 else if (Record->hasNonTrivialDestructor())
7211 Record->setParamDestroyedInCallee(CanPass);
7213 if (getLangOpts().ForceEmitVTables) {
7216 MarkVTableUsed(Record->getInnerLocStart(), Record);
7219 if (getLangOpts().
CUDA) {
7220 if (Record->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>())
7222 else if (Record->hasAttr<CUDADeviceBuiltinTextureTypeAttr>())
7238 unsigned FieldQuals,
bool ConstRHS) {
7239 unsigned LHSQuals = 0;
7241 LHSQuals = FieldQuals;
7243 unsigned RHSQuals = FieldQuals;
7264 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
7270 : S(S), UseLoc(UseLoc) {
7271 bool DiagnosedMultipleConstructedBases =
false;
7277 for (
auto *D : Shadow->
redecls()) {
7278 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
7279 auto *DNominatedBase = DShadow->getNominatedBaseClass();
7280 auto *DConstructedBase = DShadow->getConstructedBaseClass();
7282 InheritedFromBases.insert(
7283 std::make_pair(DNominatedBase->getCanonicalDecl(),
7284 DShadow->getNominatedBaseClassShadowDecl()));
7285 if (DShadow->constructsVirtualBase())
7286 InheritedFromBases.insert(
7287 std::make_pair(DConstructedBase->getCanonicalDecl(),
7288 DShadow->getConstructedBaseClassShadowDecl()));
7290 assert(DNominatedBase == DConstructedBase);
7295 if (!ConstructedBase) {
7296 ConstructedBase = DConstructedBase;
7297 ConstructedBaseIntroducer = D->getIntroducer();
7298 }
else if (ConstructedBase != DConstructedBase &&
7300 if (!DiagnosedMultipleConstructedBases) {
7301 S.Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
7302 << Shadow->getTargetDecl();
7303 S.Diag(ConstructedBaseIntroducer->getLocation(),
7304 diag::note_ambiguous_inherited_constructor_using)
7306 DiagnosedMultipleConstructedBases = true;
7308 S.
Diag(D->getIntroducer()->getLocation(),
7309 diag::note_ambiguous_inherited_constructor_using)
7310 << DConstructedBase;
7314 if (DiagnosedMultipleConstructedBases)
7315 Shadow->setInvalidDecl();
7321 std::pair<CXXConstructorDecl *, bool>
7323 auto It = InheritedFromBases.find(
Base->getCanonicalDecl());
7324 if (It == InheritedFromBases.end())
7325 return std::make_pair(
nullptr,
false);
7329 return std::make_pair(
7331 It->second->constructsVirtualBase());
7334 return std::make_pair(Ctor,
false);
7353 if (InheritedCtor) {
7356 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
7358 return BaseCtor->isConstexpr();
7426 if (Ctor && ClassDecl->
isUnion())
7445 for (
const auto &B : ClassDecl->
bases()) {
7446 const RecordType *BaseType = B.getType()->getAs<RecordType>();
7451 InheritedCtor, Inherited))
7462 for (
const auto *F : ClassDecl->
fields()) {
7463 if (F->isInvalidDecl())
7468 if (
const RecordType *RecordTy = BaseType->getAs<RecordType>()) {
7471 BaseType.getCVRQualifiers(),
7472 ConstArg && !F->isMutable()))
7486struct ComputingExceptionSpec {
7497 ~ComputingExceptionSpec() {
7516 if (DFK.isSpecialMember())
7518 S, Loc, cast<CXXMethodDecl>(FD), DFK.asSpecialMember(),
nullptr);
7519 if (DFK.isComparison())
7521 DFK.asComparison());
7524 assert(CD->getInheritedConstructor() &&
7525 "only defaulted functions and inherited constructors have implicit "
7528 S, Loc, CD->getInheritedConstructor().getShadowDecl());
7555 auto ESI = IES.getExceptionSpec();
7558 UpdateExceptionSpec(FD, ESI);
7571 UnusedPrivateFields.clear();
7574 ? CheckExplicitlyDefaultedSpecialMember(cast<CXXMethodDecl>(FD),
7577 : CheckExplicitlyDefaultedComparison(S, FD, DefKind.
asComparison()))
7587 "not an explicitly-defaulted special member");
7597 bool HadError =
false;
7609 bool DeleteOnTypeMismatch = getLangOpts().CPlusPlus20 &&
First;
7610 bool ShouldDeleteForTypeMismatch =
false;
7611 unsigned ExpectedParams = 1;
7612 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
7622 if (DeleteOnTypeMismatch)
7623 ShouldDeleteForTypeMismatch =
true;
7633 bool CanHaveConstParam =
false;
7634 if (CSM == CXXCopyConstructor)
7636 else if (CSM == CXXCopyAssignment)
7640 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
7642 ReturnType =
Type->getReturnType();
7649 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
7650 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
7651 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
7656 if (
Type->getMethodQuals().hasConst() ||
Type->getMethodQuals().hasVolatile()) {
7657 if (DeleteOnTypeMismatch)
7658 ShouldDeleteForTypeMismatch =
true;
7661 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
7669 bool HasConstParam =
false;
7670 if (ExpectedParams && ArgType->isReferenceType()) {
7676 if (DeleteOnTypeMismatch)
7677 ShouldDeleteForTypeMismatch =
true;
7680 diag::err_defaulted_special_member_volatile_param) << CSM;
7685 if (HasConstParam && !CanHaveConstParam) {
7686 if (DeleteOnTypeMismatch)
7687 ShouldDeleteForTypeMismatch =
true;
7688 else if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
7690 diag::err_defaulted_special_member_copy_const_param)
7691 << (CSM == CXXCopyAssignment);
7696 diag::err_defaulted_special_member_move_const_param)
7697 << (CSM == CXXMoveAssignment);
7701 }
else if (ExpectedParams) {
7704 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
7732 (getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
7733 : isa<CXXConstructorDecl>(MD))) &&
7737 ? diag::err_incorrect_defaulted_consteval
7738 : diag::err_incorrect_defaulted_constexpr)
7750 ? ConstexprSpecKind::Consteval
7751 : ConstexprSpecKind::Constexpr)
7752 : ConstexprSpecKind::Unspecified);
7754 if (!
Type->hasExceptionSpec()) {
7767 if (ShouldDeleteForTypeMismatch || ShouldDeleteSpecialMember(MD, CSM)) {
7770 if (!inTemplateInstantiation() && !HadError) {
7772 if (ShouldDeleteForTypeMismatch) {
7774 }
else if (ShouldDeleteSpecialMember(MD, CSM,
nullptr,
7777 Diag(DefaultLoc, diag::note_replace_equals_default_to_delete)
7781 if (ShouldDeleteForTypeMismatch && !HadError) {
7783 diag::warn_cxx17_compat_defaulted_method_type_mismatch) << CSM;
7789 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
7790 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
7791 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
7812template<
typename Derived,
typename ResultList,
typename Result,
7814class DefaultedComparisonVisitor {
7819 DefaultedComparisonKind DCK)
7820 : S(S), RD(RD), FD(FD), DCK(DCK) {
7824 Fns.assign(Info->getUnqualifiedLookups().begin(),
7825 Info->getUnqualifiedLookups().end());
7829 ResultList visit() {
7837 case DefaultedComparisonKind::None:
7838 llvm_unreachable(
"not a defaulted comparison");
7840 case DefaultedComparisonKind::Equal:
7841 case DefaultedComparisonKind::ThreeWay:
7842 getDerived().visitSubobjects(Results, RD, ParamLvalType.
getQualifiers());
7845 case DefaultedComparisonKind::NotEqual:
7846 case DefaultedComparisonKind::Relational:
7847 Results.add(getDerived().visitExpandedSubobject(
7848 ParamLvalType, getDerived().getCompleteObject()));
7851 llvm_unreachable(
"");
7855 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
7861 bool visitSubobjects(ResultList &Results,
CXXRecordDecl *Record,
7866 if (Results.add(getDerived().visitSubobject(
7868 getDerived().getBase(&
Base))))
7875 if (
Field->isUnnamedBitfield())
7878 if (
Field->isAnonymousStructOrUnion()) {
7879 if (visitSubobjects(Results,
Field->getType()->getAsCXXRecordDecl(),
7887 if (
Field->isMutable())
7892 if (Results.add(getDerived().visitSubobject(
7893 FieldType, getDerived().getField(Field))))
7901 Result visitSubobject(
QualType Type, Subobject Subobj) {
7904 if (
auto *CAT = dyn_cast_or_null<ConstantArrayType>(AT))
7905 return getDerived().visitSubobjectArray(CAT->getElementType(),
7906 CAT->getSize(), Subobj);
7907 return getDerived().visitExpandedSubobject(
Type, Subobj);
7910 Result visitSubobjectArray(
QualType Type,
const llvm::APInt &Size,
7912 return getDerived().visitSubobject(
Type, Subobj);
7919 DefaultedComparisonKind DCK;
7925struct DefaultedComparisonInfo {
7930 static DefaultedComparisonInfo deleted() {
7931 DefaultedComparisonInfo
Deleted;
7936 bool add(
const DefaultedComparisonInfo &R) {
7946struct DefaultedComparisonSubobject {
7954class DefaultedComparisonAnalyzer
7955 :
public DefaultedComparisonVisitor<DefaultedComparisonAnalyzer,
7956 DefaultedComparisonInfo,
7957 DefaultedComparisonInfo,
7958 DefaultedComparisonSubobject> {
7960 enum DiagnosticKind { NoDiagnostics, ExplainDeleted, ExplainConstexpr };
7963 DiagnosticKind Diagnose;
7966 using Base = DefaultedComparisonVisitor;
7967 using Result = DefaultedComparisonInfo;
7968 using Subobject = DefaultedComparisonSubobject;
7973 DefaultedComparisonKind DCK,
7974 DiagnosticKind Diagnose = NoDiagnostics)
7975 :
Base(S, RD, FD, DCK), Diagnose(Diagnose) {}
7978 if ((DCK == DefaultedComparisonKind::Equal ||
7979 DCK == DefaultedComparisonKind::ThreeWay) &&
7984 if (Diagnose == ExplainDeleted) {
7988 return Result::deleted();
7991 return Base::visit();
7995 Subobject getCompleteObject() {
7996 return Subobject{Subobject::CompleteObject, RD, FD->
getLocation()};
8000 return Subobject{Subobject::Base,
Base->getType()->getAsCXXRecordDecl(),
8001 Base->getBaseTypeLoc()};
8005 return Subobject{Subobject::Member,
Field,
Field->getLocation()};
8008 Result visitExpandedSubobject(
QualType Type, Subobject Subobj) {
8013 if (Diagnose == ExplainDeleted) {
8014 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_reference_member)
8017 return Result::deleted();
8022 Expr *Args[] = {&Xi, &Xi};
8026 assert(OO !=
OO_None &&
"not an overloaded operator!");
8027 return visitBinaryOperator(OO, Args, Subobj);
8041 !SpaceshipCandidates));
8046 CandidateSet.exclude(FD);
8048 if (Args[0]->
getType()->isOverloadableType())
8059 switch (CandidateSet.BestViableFunction(S, FD->
getLocation(), Best)) {
8065 if ((DCK == DefaultedComparisonKind::NotEqual ||
8066 DCK == DefaultedComparisonKind::Relational) &&
8067 !Best->RewriteKind) {
8068 if (Diagnose == ExplainDeleted) {
8069 if (Best->Function) {
8070 S.
Diag(Best->Function->getLocation(),
8071 diag::note_defaulted_comparison_not_rewritten_callee)
8074 assert(Best->Conversions.size() == 2 &&
8075 Best->Conversions[0].isUserDefined() &&
8076 "non-user-defined conversion from class to built-in "
8078 S.
Diag(Best->Conversions[0]
8079 .UserDefined.FoundConversionFunction.getDecl()
8081 diag::note_defaulted_comparison_not_rewritten_conversion)
8085 return Result::deleted();
8095 CXXRecordDecl *ArgClass = Args[0]->getType()->getAsCXXRecordDecl();
8096 if (ArgClass && Best->FoundDecl.getDecl() &&
8097 Best->FoundDecl.getDecl()->isCXXClassMember()) {
8098 QualType ObjectType = Subobj.Kind == Subobject::Member
8099 ? Args[0]->getType()
8102 ArgClass, Best->FoundDecl, ObjectType, Subobj.Loc,
8103 Diagnose == ExplainDeleted
8104 ? S.
PDiag(diag::note_defaulted_comparison_inaccessible)
8105 << FD << Subobj.Kind << Subobj.Decl
8107 return Result::deleted();
8110 bool NeedsDeducing =
8118 assert(!BestFD->isDeleted() &&
"wrong overload resolution result");
8120 if (Diagnose == ExplainConstexpr && !BestFD->isConstexpr()) {
8121 if (Subobj.Kind != Subobject::CompleteObject)
8122 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_not_constexpr)
8123 << Subobj.
Kind << Subobj.Decl;
8124 S.
Diag(BestFD->getLocation(),
8125 diag::note_defaulted_comparison_not_constexpr_here);
8127 return Result::deleted();
8129 R.Constexpr &= BestFD->isConstexpr();
8131 if (NeedsDeducing) {
8136 if (BestFD->getReturnType()->isUndeducedType() &&
8142 if (Diagnose == NoDiagnostics) {
8145 diag::err_defaulted_comparison_cannot_deduce_undeduced_auto)
8146 << Subobj.
Kind << Subobj.Decl;
8149 diag::note_defaulted_comparison_cannot_deduce_undeduced_auto)
8150 << Subobj.
Kind << Subobj.Decl;
8151 S.
Diag(BestFD->getLocation(),
8152 diag::note_defaulted_comparison_cannot_deduce_callee)
8153 << Subobj.
Kind << Subobj.Decl;
8155 return Result::deleted();
8158 BestFD->getCallResultType());
8160 if (Diagnose == ExplainDeleted) {
8161 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_cannot_deduce)
8162 << Subobj.
Kind << Subobj.Decl
8163 << BestFD->getCallResultType().withoutLocalFastQualifiers();
8164 S.
Diag(BestFD->getLocation(),
8165 diag::note_defaulted_comparison_cannot_deduce_callee)
8166 << Subobj.
Kind << Subobj.Decl;
8168 return Result::deleted();
8170 R.Category = Info->Kind;
8173 QualType T = Best->BuiltinParamTypes[0];
8174 assert(T == Best->BuiltinParamTypes[1] &&
8175 "builtin comparison for different types?");
8176 assert(Best->BuiltinParamTypes[2].isNull() &&
8177 "invalid builtin comparison");
8179 if (NeedsDeducing) {
8180 std::optional<ComparisonCategoryType> Cat =
8182 assert(Cat &&
"no category for builtin comparison?");
8193 if (Diagnose == ExplainDeleted) {
8196 Kind = OO == OO_EqualEqual ? 1 : 2;
8197 CandidateSet.NoteCandidates(
8199 Subobj.Loc, S.
PDiag(diag::note_defaulted_comparison_ambiguous)
8200 << FD << Kind << Subobj.Kind << Subobj.Decl),
8203 R = Result::deleted();
8207 if (Diagnose == ExplainDeleted) {
8208 if ((DCK == DefaultedComparisonKind::NotEqual ||
8209 DCK == DefaultedComparisonKind::Relational) &&
8210 !Best->RewriteKind) {
8211 S.
Diag(Best->Function->getLocation(),
8212 diag::note_defaulted_comparison_not_rewritten_callee)
8216 diag::note_defaulted_comparison_calls_deleted)
8217 << FD << Subobj.
Kind << Subobj.Decl;
8221 R = Result::deleted();
8227 if (OO == OO_Spaceship &&
8231 if (!R.add(visitBinaryOperator(OO_EqualEqual, Args, Subobj,
8233 R.add(visitBinaryOperator(OO_Less, Args, Subobj, &CandidateSet));
8237 if (Diagnose == ExplainDeleted) {
8238 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function)
8239 << FD << (OO == OO_EqualEqual || OO == OO_ExclaimEqual)
8240 << Subobj.
Kind << Subobj.Decl;
8244 if (SpaceshipCandidates) {
8245 SpaceshipCandidates->NoteCandidates(
8250 diag::note_defaulted_comparison_no_viable_function_synthesized)
8251 << (OO == OO_EqualEqual ? 0 : 1);
8254 CandidateSet.NoteCandidates(
8259 R = Result::deleted();
8268struct StmtListResult {
8269 bool IsInvalid =
false;
8272 bool add(
const StmtResult &S) {
8273 IsInvalid |= S.isInvalid();
8276 Stmts.push_back(S.get());
8283class DefaultedComparisonSynthesizer
8284 :
public DefaultedComparisonVisitor<DefaultedComparisonSynthesizer,
8285 StmtListResult, StmtResult,
8286 std::pair<ExprResult, ExprResult>> {
8288 unsigned ArrayDepth = 0;
8291 using Base = DefaultedComparisonVisitor;
8292 using ExprPair = std::pair<ExprResult, ExprResult>;
8297 DefaultedComparisonKind DCK,
8299 :
Base(S, RD, FD, DCK), Loc(BodyLoc) {}
8302 StmtResult build() {
8305 StmtListResult Stmts = visit();
8306 if (Stmts.IsInvalid)
8311 case DefaultedComparisonKind::None:
8312 llvm_unreachable(
"not a defaulted comparison");
8314 case DefaultedComparisonKind::Equal: {
8323 auto OldStmts = std::move(Stmts.Stmts);
8324 Stmts.Stmts.clear();
8327 auto FinishCmp = [&] {
8328 if (
Expr *Prior = CmpSoFar.
get()) {
8330 if (RetVal.
isUnset() && Stmts.Stmts.empty())
8333 else if (Stmts.add(buildIfNotCondReturnFalse(Prior)))
8339 for (
Stmt *EAsStmt : llvm::reverse(OldStmts)) {
8340 Expr *E = dyn_cast<Expr>(EAsStmt);
8343 if (FinishCmp() || Stmts.add(EAsStmt))
8358 std::reverse(Stmts.Stmts.begin(), Stmts.Stmts.end());
8365 case DefaultedComparisonKind::ThreeWay: {
8369 ComparisonCategoryType::StrongOrdering, Loc,
8370 Sema::ComparisonCategoryUsage::DefaultedOperator);
8376 RetVal = getDecl(EqualVD);
8379 RetVal = buildStaticCastToR(RetVal.
get());
8383 case DefaultedComparisonKind::NotEqual:
8384 case DefaultedComparisonKind::Relational:
8385 RetVal =
cast<Expr>(Stmts.Stmts.pop_back_val());
8411 ExprPair getCompleteObject() {
8414 if (isa<CXXMethodDecl>(FD)) {
8428 ExprPair Obj = getCompleteObject();
8429 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8439 ExprPair Obj = getCompleteObject();
8440 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8455 if (
Cond.isInvalid())
8463 assert(!False.
isInvalid() &&
"should never fail");
8465 if (ReturnFalse.isInvalid())
8468 return S.
ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc,
nullptr,
8470 Sema::ConditionKind::Boolean),
8474 StmtResult visitSubobjectArray(
QualType Type, llvm::APInt Size,
8483 llvm::raw_svector_ostream OS(Str);
8484 OS <<
"i" << ArrayDepth;
8495 auto IterRef = [&] {
8499 assert(!Ref.
isInvalid() &&
"can't reference our own variable?");
8505 Loc, BO_NE, IterRef(),
8507 assert(!
Cond.isInvalid() &&
"should never fail");
8511 assert(!
Inc.isInvalid() &&
"should never fail");
8519 Subobj.first = Index(Subobj.first);
8520 Subobj.second = Index(Subobj.second);
8524 StmtResult Substmt = visitSubobject(
Type, Subobj);
8527 if (Substmt.isInvalid())
8533 if (
Expr *ElemCmp = dyn_cast<Expr>(Substmt.get())) {
8534 assert(DCK == DefaultedComparisonKind::Equal &&
8535 "should have non-expression statement");
8536 Substmt = buildIfNotCondReturnFalse(ElemCmp);
8537 if (Substmt.isInvalid())
8544 Sema::ConditionKind::Boolean),
8549 StmtResult visitExpandedSubobject(
QualType Type, ExprPair Obj) {
8550 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8558 Obj.second.get(),
true,
8566 case DefaultedComparisonKind::None:
8567 llvm_unreachable(
"not a defaulted comparison");
8569 case DefaultedComparisonKind::Equal:
8577 case DefaultedComparisonKind::ThreeWay: {
8582 Op = buildStaticCastToR(Op.
get());
8607 if (
Comp.isInvalid())
8610 nullptr, Loc,
Comp.get(), Sema::ConditionKind::Boolean);
8611 if (
Cond.isInvalid())
8615 VDRef = getDecl(VD);
8623 return S.
ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc, InitStmt,
Cond,
8628 case DefaultedComparisonKind::NotEqual:
8629 case DefaultedComparisonKind::Relational:
8634 llvm_unreachable(
"");
8640 assert(!R->
isUndeducedType() &&
"type should have been deduced already");
8671 if (Op == OO_Spaceship) {
8672 Lookup(OO_ExclaimEqual);
8674 Lookup(OO_EqualEqual);
8680 assert(DCK != DefaultedComparisonKind::None &&
"not a defaulted comparison");
8689 Context, Operators.
pairs()));
8704 assert(!MD->isStatic() &&
"comparison function cannot be a static member");
8706 if (MD->getRefQualifier() ==
RQ_RValue) {
8707 Diag(MD->getLocation(), diag::err_ref_qualifier_comparison_operator);
8714 FPT->getParamTypes(), EPI));
8721 if (!MD->isConst()) {
8724 InsertLoc = getLocForEndOfToken(Loc.getRParenLoc());
8727 if (!MD->isImplicit()) {
8728 Diag(MD->getLocation(), diag::err_defaulted_comparison_non_const)
8737 FPT->getParamTypes(), EPI));
8740 if (MD->isVolatile()) {
8741 Diag(MD->getLocation(), diag::err_volatile_comparison_operator);
8748 FPT->getParamTypes(), EPI));
8756 <<
int(IsMethod) <<
int(DCK);
8762 QualType ParmTy = Param->getType();
8767 bool Ok = !IsMethod;
8772 CTy = Ref->getPointeeType();
8783 }
else if (
auto *CRD = CTy->getAsRecordDecl()) {
8800 <<
int(DCK) << ParmTy << RefTy <<
int(!IsMethod) << PlainTy
8801 << Param->getSourceRange();
8803 assert(!IsMethod &&
"should know expected type for method");
8805 diag::err_defaulted_comparison_param_unknown)
8806 <<
int(DCK) << ParmTy << Param->getSourceRange();
8812 Diag(FD->
getLocation(), diag::err_defaulted_comparison_param_mismatch)
8814 << ParmTy << Param->getSourceRange();
8819 assert(RD &&
"must have determined class");
8828 diag::err_defaulted_comparison_not_friend,
int(DCK),
8833 return FD->getCanonicalDecl() ==
8834 F->getFriendDecl()->getCanonicalDecl();
8837 <<
int(DCK) <<
int(0) << RD;
8846 if (DCK != DefaultedComparisonKind::ThreeWay &&
8849 Diag(FD->
getLocation(), diag::err_defaulted_comparison_return_type_not_bool)
8858 DCK == DefaultedComparisonKind::ThreeWay &&
8859 RT->getContainedDeducedType() &&
8861 RT->getContainedAutoType()->isConstrained())) {
8863 diag::err_defaulted_comparison_deduced_return_type_not_auto)
8875 DefaultedComparisonInfo Info =
8876 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK).visit();
8890 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8891 DefaultedComparisonAnalyzer::ExplainDeleted)
8902 diag::note_previous_declaration);
8911 if (!inTemplateInstantiation() && !FD->
isImplicit()) {
8914 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8915 DefaultedComparisonAnalyzer::ExplainDeleted)
8926 if (DCK == DefaultedComparisonKind::ThreeWay &&
8933 QualType Cat = CheckComparisonCategoryType(
8934 Info.Category, RetLoc, ComparisonCategoryUsage::DefaultedOperator);
8966 ? diag::warn_cxx23_compat_defaulted_comparison_constexpr_mismatch
8967 : diag::ext_defaulted_comparison_constexpr_mismatch)
8969 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8970 DefaultedComparisonAnalyzer::ExplainConstexpr)
8991 EPI.ExceptionSpec.SourceDecl = FD;
8993 FPT->getParamTypes(), EPI));
9005 pushCodeSynthesisContext(Ctx);
9007 if (
FunctionDecl *EqualEqual = SubstSpaceshipAsEqualEqual(RD, Spaceship))
9008 EqualEqual->setImplicit();
9010 popCodeSynthesisContext();
9023 Scope.addContextNote(UseLoc);
9030 CXXRecordDecl *RD = PT.getNonReferenceType()->getAsCXXRecordDecl();
9034 DefaultedComparisonSynthesizer(*
this, RD, FD, DCK, BodyLoc).build();
9048 L->CompletedImplicitDefinition(FD);
9055 ComputingExceptionSpec CES(S, FD, Loc);
9076 S, Sema::ExpressionEvaluationContext::Unevaluated);
9082 DefaultedComparisonSynthesizer(S, RD, FD, DCK, BodyLoc).build();
9083 if (!Body.isInvalid())
9096 decltype(DelayedOverridingExceptionSpecChecks) Overriding;
9097 decltype(DelayedEquivalentExceptionSpecChecks)
Equivalent;
9099 std::swap(Overriding, DelayedOverridingExceptionSpecChecks);
9100 std::swap(
Equivalent, DelayedEquivalentExceptionSpecChecks);
9104 for (
auto &Check : Overriding)
9105 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
9110 CheckEquivalentExceptionSpec(Check.second, Check.first);
9116template<
typename Derived>
9117struct SpecialMemberVisitor {
9124 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
9128 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
9133 IsConstructor =
true;
9137 IsAssignment =
true;
9142 llvm_unreachable(
"invalid special member kind");
9146 if (const ReferenceType *RT =
9147 MD->getParamDecl(0)->getType()->getAs<ReferenceType>())
9148 ConstArg = RT->getPointeeType().isConstQualified();
9152 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
9155 bool isMove()
const {
9161 unsigned Quals,
bool IsMutable) {
9163 ConstArg && !IsMutable);
9180 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
9187 return B->getBaseTypeLoc();
9189 return Subobj.get<
FieldDecl*>()->getLocation();
9194 VisitNonVirtualBases,
9199 VisitPotentiallyConstructedBases,
9205 bool visit(BasesToVisit Bases) {
9208 if (Bases == VisitPotentiallyConstructedBases)
9209 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
9211 for (
auto &B : RD->
bases())
9212 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
9213 getDerived().visitBase(&B))
9216 if (Bases == VisitAllBases)
9217 for (
auto &B : RD->
vbases())
9218 if (getDerived().visitBase(&B))
9221 for (
auto *F : RD->
fields())
9222 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
9223 getDerived().visitField(F))
9232struct SpecialMemberDeletionInfo
9233 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
9238 bool AllFieldsAreConst;
9243 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
9244 Loc(MD->getLocation()), AllFieldsAreConst(
true) {}
9255 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
9258 bool shouldDeleteForField(
FieldDecl *FD);
9259 bool shouldDeleteForAllConstMembers();
9261 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
9263 bool shouldDeleteForSubobjectCall(Subobject Subobj,
9265 bool IsDtorCallInCtor);
9273bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
9294bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
9296 bool IsDtorCallInCtor) {
9303 DiagKind = !
Decl ? 0 : 1;
9306 else if (!isAccessible(Subobj,
Decl))
9308 else if (!IsDtorCallInCtor && Field &&
Field->getParent()->isUnion() &&
9309 !
Decl->isTrivial()) {
9335 diag::note_deleted_special_member_class_subobject)
9336 << getEffectiveCSM() << MD->
getParent() <<
true
9337 <<
Field << DiagKind << IsDtorCallInCtor <<
false;
9341 diag::note_deleted_special_member_class_subobject)
9342 << getEffectiveCSM() << MD->
getParent() <<
false
9343 <<
Base->getType() << DiagKind << IsDtorCallInCtor
9357bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
9360 bool IsMutable =
Field &&
Field->isMutable();
9377 Field &&
Field->hasInClassInitializer()) &&
9378 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
9385 if (IsConstructor) {
9388 false,
false,
false,
false,
false);
9389 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
9396bool SpecialMemberDeletionInfo::shouldDeleteForVariantObjCPtrMember(
9412 diag::note_deleted_special_member_class_subobject)
9413 << getEffectiveCSM() << ParentClass <<
true
9414 << FD << 4 <<
false <<
true;
9431 if (
auto *BaseCtor = SMOR.
getMethod()) {
9436 if (BaseCtor->isDeleted() && Diagnose) {
9438 diag::note_deleted_special_member_class_subobject)
9439 << getEffectiveCSM() << MD->
getParent() <<
false
9440 <<
Base->getType() << 1 <<
false
9444 return BaseCtor->isDeleted();
9446 return shouldDeleteForClassSubobject(BaseClass,
Base, 0);
9451bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
9455 if (inUnion() && shouldDeleteForVariantObjCPtrMember(FD, FieldType))
9463 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9464 << !!ICI << MD->
getParent() << FD << FieldType << 0;
9474 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9480 AllFieldsAreConst =
false;
9486 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
9490 }
else if (IsAssignment) {
9495 << isMove() << MD->
getParent() << FD << FieldType << 0;
9510 if (!inUnion() && FieldRecord->
isUnion() &&
9512 bool AllVariantFieldsAreConst =
true;
9515 for (
auto *UI : FieldRecord->
fields()) {
9518 if (shouldDeleteForVariantObjCPtrMember(&*UI, UnionFieldType))
9522 AllVariantFieldsAreConst =
false;
9525 if (UnionFieldRecord &&
9526 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
9536 diag::note_deleted_default_ctor_all_const)
9547 if (shouldDeleteForClassSubobject(FieldRecord, FD,
9558bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
9562 bool AnyFields =
false;
9564 if ((AnyFields = !F->isUnnamedBitfield()))
9570 diag::note_deleted_default_ctor_all_const)
9596 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
9605 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
9614 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
9620 bool DeletesOnlyMatchingCopy =
9621 getLangOpts().MSVCCompat &&
9625 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
9626 if (!Diagnose)
return true;
9629 for (
auto *I : RD->
ctors()) {
9630 if (I->isMoveConstructor()) {
9631 UserDeclaredMove = I;
9635 assert(UserDeclaredMove);
9637 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
9638 if (!Diagnose)
return true;
9641 for (
auto *I : RD->
methods()) {
9642 if (I->isMoveAssignmentOperator()) {
9643 UserDeclaredMove = I;
9647 assert(UserDeclaredMove);
9650 if (UserDeclaredMove) {
9652 diag::note_deleted_copy_user_declared_move)
9653 << (CSM == CXXCopyAssignment) << RD
9665 if (CSM == CXXDestructor && MD->
isVirtual()) {
9670 OperatorDelete,
false)) {
9677 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
9685 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
9686 : SMI.VisitPotentiallyConstructedBases))
9689 if (SMI.shouldDeleteForAllConstMembers())
9692 if (getLangOpts().
CUDA) {
9699 assert(ICI || CSM == getSpecialMember(MD));
9702 RealCSM = getSpecialMember(MD);
9704 return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
9705 SMI.ConstArg, Diagnose);
9713 assert(DFK &&
"not a defaultable function");
9717 ShouldDeleteSpecialMember(cast<CXXMethodDecl>(FD), DFK.
asSpecialMember(),
9720 DefaultedComparisonAnalyzer(
9722 DFK.
asComparison(), DefaultedComparisonAnalyzer::ExplainDeleted)
9744 *Selected =
nullptr;
9748 llvm_unreachable(
"not a special member");
9766 for (
auto *CI : RD->
ctors()) {
9767 if (!CI->isDefaultConstructor())
9774 *Selected = DefCtor;
9807 }
else if (!Selected) {
9815 goto NeedOverloadResolution;
9825 }
else if (!Selected) {
9830 goto NeedOverloadResolution;
9834 NeedOverloadResolution:
9862 llvm_unreachable(
"unknown special method kind");
9866 for (
auto *CI : RD->
ctors())
9867 if (!CI->isImplicit())
9874 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
9904 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
9912 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
9915 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
9916 }
else if (!Selected)
9917 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
9922 << Kind << SubType.getUnqualifiedType() << CSM;
9924 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
9925 << Kind << SubType.getUnqualifiedType() << CSM;
9930 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
9931 << Kind << SubType.getUnqualifiedType() << CSM;
9949 for (
const auto *FI : RD->
fields()) {
9950 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
9956 if (FI->isAnonymousStructOrUnion()) {
9958 CSM, ConstArg, TAH, Diagnose))
9969 S.
Diag(FI->getLocation(), diag::note_nontrivial_default_member_init)
9980 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
9985 bool ConstRHS = ConstArg && !FI->isMutable();
9999 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
10010 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
10014 bool ConstArg =
false;
10020 case CXXDefaultConstructor:
10021 case CXXDestructor:
10025 case CXXCopyConstructor:
10026 case CXXCopyAssignment: {
10038 const bool ClangABICompat14 = Context.
getLangOpts().getClangABICompat() <=
10039 LangOptions::ClangABI::Ver14;
10042 ClangABICompat14)) {
10055 case CXXMoveConstructor:
10056 case CXXMoveAssignment: {
10072 llvm_unreachable(
"not a special member");
10078 diag::note_nontrivial_default_arg)
10097 for (
const auto &BI : RD->
bases())
10120 if (CSM == CXXDestructor && MD->
isVirtual()) {
10138 Diag(BS.
getBeginLoc(), diag::note_nontrivial_has_virtual) << RD << 1;
10143 for (
const auto *MI : RD->
methods()) {
10144 if (MI->isVirtual()) {
10146 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
10151 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
10159struct FindHiddenVirtualMethod {
10167 static bool CheckMostOverridenMethods(
10169 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
10173 if (CheckMostOverridenMethods(O, Methods))
10184 Specifier->getType()->castAs<RecordType>()->getDecl();
10189 bool foundSameNameMethod =
false;
10196 foundSameNameMethod =
true;
10213 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
10214 overloadedMethods.push_back(MD);
10218 if (foundSameNameMethod)
10219 OverloadedMethods.append(overloadedMethods.begin(),
10220 overloadedMethods.end());
10221 return foundSameNameMethod;
10228 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
10246 FindHiddenVirtualMethod FHVM;
10257 ND = shad->getTargetDecl();
10263 OverloadedMethods = FHVM.OverloadedMethods;
10268 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
10271 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
10272 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
10283 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
10287 FindHiddenVirtualMethods(MD, OverloadedMethods);
10288 if (!OverloadedMethods.empty()) {
10290 << MD << (OverloadedMethods.size() > 1);
10292 NoteHiddenVirtualMethods(MD, OverloadedMethods);
10297 auto PrintDiagAndRemoveAttr = [&](
unsigned N) {
10300 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10301 diag::ext_cannot_use_trivial_abi) << &RD;
10302 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10303 diag::note_cannot_use_trivial_abi_reason) << &RD <<
N;
10309 auto HasNonDeletedCopyOrMoveConstructor = [&]() {
10321 if (CD->isCopyOrMoveConstructor() && !CD->isDeleted())
10326 if (!HasNonDeletedCopyOrMoveConstructor()) {
10327 PrintDiagAndRemoveAttr(0);
10333 PrintDiagAndRemoveAttr(1);
10337 for (
const auto &B : RD.
bases()) {
10340 if (!B.getType()->isDependentType() &&
10341 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) {
10342 PrintDiagAndRemoveAttr(2);
10346 if (B.isVirtual()) {
10347 PrintDiagAndRemoveAttr(3);
10352 for (
const auto *FD : RD.
fields()) {
10357 PrintDiagAndRemoveAttr(4);
10362 if (!RT->isDependentType() &&
10363 !cast<CXXRecordDecl>(RT->getDecl())->canPassInRegisters()) {
10364 PrintDiagAndRemoveAttr(5);
10376 AdjustDeclIfTemplate(
TagDecl);
10379 if (AL.getKind() != ParsedAttr::AT_Visibility)
10382 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored) << AL;
10385 ActOnFields(S, RLoc,
TagDecl,
10388 reinterpret_cast<Decl **
>(FieldCollector->getCurFields()),
10389 FieldCollector->getCurNumFields()),
10390 LBrac, RBrac, AttrList);
10392 CheckCompletedCXXClass(S, cast<CXXRecordDecl>(
TagDecl));
10407 FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Friend->getFriendDecl());
10412 Spaceships.clear();
10418 Spaceships.push_back(FD);
10427 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10428 if (FD->isExplicitlyDefaulted())
10429 Spaceships.push_back(FD);
10444 ++getASTContext().NumImplicitDefaultConstructors;
10447 DeclareImplicitDefaultConstructor(ClassDecl);
10451 ++getASTContext().NumImplicitCopyConstructors;
10458 DeclareImplicitCopyConstructor(ClassDecl);
10469 DeclareImplicitCopyConstructor(ClassDecl);
10474 ++getASTContext().NumImplicitMoveConstructors;
10478 DeclareImplicitMoveConstructor(ClassDecl);
10482 ++getASTContext().NumImplicitCopyAssignmentOperators;
10491 DeclareImplicitCopyAssignment(ClassDecl);
10495 ++getASTContext().NumImplicitMoveAssignmentOperators;
10501 DeclareImplicitMoveAssignment(ClassDecl);
10505 ++getASTContext().NumImplicitDestructors;
10513 DeclareImplicitDestructor(ClassDecl);
10526 if (getLangOpts().
CPlusPlus20 && !inTemplateInstantiation()) {
10529 DefaultedSpaceships);
10530 for (
auto *FD : DefaultedSpaceships)
10531 DeclareImplicitEqualityComparison(ClassDecl, FD);
10537 llvm::function_ref<
Scope *()> EnterScope) {
10540 AdjustDeclIfTemplate(D);
10545 DeclContext *LookupDC = dyn_cast<DeclContext>(D);
10548 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
10549 ParameterLists.push_back(DD->getTemplateParameterList(i));
10553 ParameterLists.push_back(FTD->getTemplateParameters());
10554 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
10558 ParameterLists.push_back(VTD->getTemplateParameters());
10559 else if (
auto *PSD = dyn_cast<VarTemplatePartialSpecializationDecl>(D))
10560 ParameterLists.push_back(PSD->getTemplateParameters());
10562 }
else if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
10563 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
10564 ParameterLists.push_back(TD->getTemplateParameterList(i));
10568 ParameterLists.push_back(CTD->getTemplateParameters());
10569 else if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
10570 ParameterLists.push_back(PSD->getTemplateParameters());
10575 unsigned Count = 0;
10576 Scope *InnermostTemplateScope =
nullptr;
10580 if (Params->size() == 0)
10583 InnermostTemplateScope = EnterScope();
10585 if (Param->getDeclName()) {
10586 InnermostTemplateScope->
AddDecl(Param);
10587 IdResolver.AddDecl(Param);
10594 if (InnermostTemplateScope) {
10595 assert(LookupDC &&
"no enclosing DeclContext for template lookup");
10596 EnterTemplatedContext(InnermostTemplateScope, LookupDC);
10603 if (!RecordD)
return;
10604 AdjustDeclIfTemplate(RecordD);
10606 PushDeclContext(S, Record);
10610 if (!RecordD)
return;
10622 if (Param->getDeclName())
10623 IdResolver.AddDecl(Param);
10649 if (Param->getDeclName())
10650 IdResolver.AddDecl(Param);
10663 AdjustDeclIfTemplate(MethodD);
10672 CheckConstructor(Constructor);
10675 if (!Method->isInvalidDecl())
10676 CheckCXXDefaultArguments(Method);
10684 bool DiagOccured =
false;
10686 [DiagID, &S, &DiagOccured](
DeclSpec::TQ, StringRef QualName,
10693 DiagOccured =
true;
10732 diagnoseIgnoredQualifiers(
10771 = dyn_cast<CXXRecordDecl>(Constructor->getDeclContext());
10773 return Constructor->setInvalidDecl();
10780 if (!Constructor->isInvalidDecl() &&
10781 Constructor->hasOneParamOrDefaultArgs() &&
10782 Constructor->getTemplateSpecializationKind() !=
10784 QualType ParamType = Constructor->getParamDecl(0)->getType();
10787 SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
10788 const char *ConstRef
10789 = Constructor->getParamDecl(0)->getIdentifier() ?
"const &"
10791 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
10796 Constructor->setInvalidDecl();
10807 if (!Destructor->getOperatorDelete() && Destructor->isVirtual()) {
10810 if (!Destructor->isImplicit())
10811 Loc = Destructor->getLocation();
10817 FindDeallocationFunctionForDestructor(Loc, RD)) {
10818 Expr *ThisArg =
nullptr;
10823 if (OperatorDelete->isDestroyingOperatorDelete()) {
10824 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
10831 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
10832 assert(!This.isInvalid() &&
"couldn't form 'this' expr in dtor?");
10833 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
10834 if (This.isInvalid()) {
10837 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
10840 ThisArg = This.get();
10844 DiagnoseUseOfDecl(OperatorDelete, Loc);
10845 MarkFunctionReferenced(Loc, OperatorDelete);
10846 Destructor->setOperatorDelete(OperatorDelete, ThisArg);
10869 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
10870 else if (
const TemplateSpecializationType *TST =
10871 DeclaratorType->
getAs<TemplateSpecializationType>())
10872 if (TST->isTypeAlias())
10874 << DeclaratorType << 1;
10907 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
10968 if (After.isInvalid())
10972 R.
setEnd(After.getEnd());
11028 if (Proto->getNumParams() > 0) {
11034 }
else if (Proto->isVariadic()) {
11041 if (Proto->getReturnType() != ConvType) {
11042 bool NeedsTypedef =
false;
11046 bool PastFunctionChunk =
false;
11048 switch (Chunk.Kind) {
11050 if (!PastFunctionChunk) {
11051 if (Chunk.Fun.HasTrailingReturnType) {
11053 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
11056 PastFunctionChunk =
true;
11061 NeedsTypedef =
true;
11081 After.isValid() ? After.getBegin() :
11083 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
11084 DB << Before << After;
11086 if (!NeedsTypedef) {
11090 if (After.isInvalid() && ConvTSI) {
11098 }
else if (!Proto->getReturnType()->isDependentType()) {
11099 DB << 1 << Proto->getReturnType();
11101 DB << 2 << Proto->getReturnType();
11112 ConvType = Proto->getReturnType();
11133 Proto->getExtProtoInfo());
11139 ? diag::warn_cxx98_compat_explicit_conversion_functions
11140 : diag::ext_explicit_conversion_functions)
11149 assert(Conversion &&
"Expected to receive a conversion function declaration");
11172 if (ConvType == ClassType)
11175 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
11177 << ClassType << ConvType;
11180 << ClassType << ConvType;
11185 return ConversionTemplate;
11193struct BadSpecifierDiagnoser {
11196 ~BadSpecifierDiagnoser() {
11200 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
11204 return check(SpecLoc,
11210 if (!Specifiers.empty()) Specifiers +=
" ";
11211 Specifiers += Spec;
11216 std::string Specifiers;
11228 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
11233 if (!CurContext->getRedeclContext()->Equals(
11236 << GuidedTemplateDecl;
11237 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
11242 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
11243 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
11244 DS.isNoreturnSpecified() || DS.hasConstexprSpecifier()) {
11245 BadSpecifierDiagnoser Diagnoser(
11247 diag::err_deduction_guide_invalid_specifier);
11249 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
11250 DS.ClearStorageClassSpecs();
11254 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
11255 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
11256 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
11257 DS.ClearConstexprSpec();
11259 Diagnoser.check(DS.getConstSpecLoc(),
"const");
11260 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
11261 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
11262 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
11263 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
11264 DS.ClearTypeQualifiers();
11266 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
11267 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
11268 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
11269 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
11270 DS.ClearTypeSpecType();
11277 bool FoundFunction =
false;
11283 diag::err_deduction_guide_with_complex_decl)
11287 if (!Chunk.Fun.hasTrailingReturnType())
11289 diag::err_deduction_guide_no_trailing_return_type);
11294 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
11296 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
11297 assert(TSI &&
"deduction guide has valid type but invalid return type?");
11298 bool AcceptableReturnType =
false;
11299 bool MightInstantiateToSpecialization =
false;
11302 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
11303 bool TemplateMatches =
11305 auto TKind = SpecifiedName.
getKind();
11311 if (SimplyWritten && TemplateMatches)
11312 AcceptableReturnType =
true;
11321 MightInstantiateToSpecialization =
true;
11324 if (!AcceptableReturnType)
11326 diag::err_deduction_guide_bad_trailing_return_type)
11327 << GuidedTemplate << TSI->
getType()
11328 << MightInstantiateToSpecialization
11333 FoundFunction =
true;
11352 assert(*IsInline != PrevNS->
isInline());
11362 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
11365 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
11383 bool IsInline = InlineLoc.
isValid();
11384 bool IsInvalid =
false;
11385 bool IsStd =
false;
11386 bool AddToKnown =
false;
11397 auto DiagnoseInlineStdNS = [&]() {
11398 assert(IsInline && II->
isStr(
"std") &&
11399 CurContext->getRedeclContext()->isTranslationUnit() &&
11400 "Precondition of DiagnoseInlineStdNS not met");
11401 Diag(InlineLoc, diag::err_inline_namespace_std)
11416 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
11417 ForExternalRedeclaration);
11418 LookupQualifiedName(R, CurContext->getRedeclContext());
11421 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
11425 if (IsInline && II->
isStr(
"std") &&
11426 CurContext->getRedeclContext()->isTranslationUnit())
11427 DiagnoseInlineStdNS();
11428 else if (IsInline != PrevNS->
isInline())
11430 &IsInline, PrevNS);
11431 }
else if (PrevDecl) {
11433 Diag(Loc, diag::err_redefinition_different_kind)
11438 }
else if (II->
isStr(
"std") &&
11439 CurContext->getRedeclContext()->isTranslationUnit()) {
11441 DiagnoseInlineStdNS();
11444 PrevNS = getStdNamespace();
11446 AddToKnown = !IsInline;
11449 AddToKnown = !IsInline;
11463 if (PrevNS && IsInline != PrevNS->
isInline())
11465 &IsInline, PrevNS);
11469 Context, CurContext, IsInline, StartLoc, Loc, II, PrevNS, IsNested);
11473 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
11474 AddPragmaAttributes(DeclRegionScope, Namespc);
11477 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
11478 PushNamespaceVisibilityAttr(
Attr, Loc);
11481 StdNamespace = Namespc;
11483 KnownNamespaces[Namespc] =
false;
11486 PushOnScopeChains(Namespc, DeclRegionScope);
11491 TU->setAnonymousNamespace(Namespc);
11496 CurContext->
addDecl(Namespc);
11527 ActOnDocumentableDecl(Namespc);
11534 PushDeclContext(NamespcScope, Namespc);
11542 return AD->getNamespace();
11543 return dyn_cast_or_null<NamespaceDecl>(D);
11549 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
11550 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
11553 if (Namespc->
hasAttr<VisibilityAttr>())
11554 PopPragmaVisibility(
true, RBrace);
11556 if (DeferredExportedNamespaces.erase(Namespc))
11561 return cast_or_null<CXXRecordDecl>(
11570 return cast_or_null<NamespaceDecl>(
11575enum UnsupportedSTLSelect {
11582struct InvalidSTLDiagnoser {
11587 QualType operator()(UnsupportedSTLSelect Sel = USS_Other, StringRef Name =
"",
11588 const VarDecl *VD =
nullptr) {
11590 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
11591 << TyForDiags << ((
int)Sel);
11592 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
11593 assert(!Name.empty());
11597 if (Sel == USS_InvalidMember) {
11610 "Looking for comparison category type outside of C++.");
11623 if (Info && FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)]) {
11626 if (RequireCompleteType(Loc, TyForDiags(Info), diag::err_incomplete_type))
11634 std::string NameForDiags =
"std::";
11636 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
11637 << NameForDiags << (
int)Usage;
11641 assert(Info->
Kind == Kind);
11649 if (RequireCompleteType(Loc, TyForDiags(Info), diag::err_incomplete_type))
11652 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags(Info)};
11655 return UnsupportedSTLError(USS_NonTrivial);
11660 if (
Base->isEmpty())
11663 return UnsupportedSTLError();
11671 if (std::distance(FIt, FEnd) != 1 ||
11672 !FIt->getType()->isIntegralOrEnumerationType()) {
11673 return UnsupportedSTLError();
11683 return UnsupportedSTLError(USS_MissingMember, MemName);
11686 assert(VD &&
"should not be null!");
11693 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
11699 return UnsupportedSTLError();
11701 MarkVariableReferenced(Loc, VD);
11706 FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)] =
true;
11713 if (!StdNamespace) {
11718 &PP.getIdentifierTable().get(
"std"),
11720 getStdNamespace()->setImplicit(
true);
11724 getStdNamespace()->clearIdentifierNamespace();
11727 return getStdNamespace();
11732 "Looking for std::initializer_list outside of C++.");
11743 if (
const RecordType *RT = Ty->
getAs<RecordType>()) {
11746 dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
11752 }
else if (
const TemplateSpecializationType *TST =
11753 Ty->
getAs<TemplateSpecializationType>()) {
11754 Template = dyn_cast_or_null<ClassTemplateDecl>(
11755 TST->getTemplateName().getAsTemplateDecl());
11756 Arguments = TST->template_arguments().begin();
11761 if (!StdInitializerList) {
11765 &PP.getIdentifierTable().get(
"initializer_list") ||
11766 !getStdNamespace()->InEnclosingNamespaceSetOf(
11774 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
11778 StdInitializerList = Template;
11786 *Element = Arguments[0].getAsType();
11793 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
11800 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
11805 Result.suppressDiagnostics();
11808 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
11816 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
11817 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
11825 if (!StdInitializerList) {
11827 if (!StdInitializerList)
11836 ElaboratedTypeKeyword::ETK_None,
11838 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
11854 return isStdInitializerList(ArgType,
nullptr);
11861 case Decl::TranslationUnit:
11863 case Decl::LinkageSpec:
11875 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
11881 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
11882 return std::make_unique<NamespaceValidatorCCC>(*
this);
11893 NamespaceValidatorCCC CCC{};
11898 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
11899 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
11900 Ident->
getName().equals(CorrectedStr);
11902 S.
PDiag(diag::err_using_directive_member_suggest)
11903 << Ident << DC << DroppedSpecifier << SS.
getRange(),
11904 S.
PDiag(diag::note_namespace_defined_here));
11907 S.
PDiag(diag::err_using_directive_suggest) << Ident,
11908 S.
PDiag(diag::note_namespace_defined_here));
11910 R.
addDecl(Corrected.getFoundDecl());
11921 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
11922 assert(NamespcName &&
"Invalid NamespcName.");
11923 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
11926 while (S->isTemplateParamScope())
11927 S = S->getParent();
11936 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
11937 LookupParsedName(R, S, &SS);
11946 NamespcName->
isStr(
"std")) {
11947 Diag(IdentLoc, diag::ext_using_undefined_std);
11948 R.
addDecl(getOrCreateStdNamespace());
11958 assert(NS &&
"expected namespace decl");
11961 DiagnoseUseOfDecl(Named, IdentLoc);
11976 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
11977 CommonAncestor = CommonAncestor->
getParent();
11981 IdentLoc, Named, CommonAncestor);
11984 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
11985 Diag(IdentLoc, diag::warn_using_directive_in_header);
11988 PushUsingDirective(S, UDir);
11990 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
11994 ProcessDeclAttributeList(S, UDir, AttrList);
12021 Diag(Name.getBeginLoc(), diag::err_using_requires_qualname);
12025 switch (Name.getKind()) {
12026 case UnqualifiedIdKind::IK_ImplicitSelfParam:
12027 case UnqualifiedIdKind::IK_Identifier:
12028 case UnqualifiedIdKind::IK_OperatorFunctionId:
12029 case UnqualifiedIdKind::IK_LiteralOperatorId:
12030 case UnqualifiedIdKind::IK_ConversionFunctionId:
12033 case UnqualifiedIdKind::IK_ConstructorName:
12034 case UnqualifiedIdKind::IK_ConstructorTemplateId:
12036 Diag(Name.getBeginLoc(),
12038 ? diag::warn_cxx98_compat_using_decl_constructor
12039 : diag::err_using_decl_constructor)
12046 case UnqualifiedIdKind::IK_DestructorName:
12047 Diag(Name.getBeginLoc(), diag::err_using_decl_destructor) << SS.
getRange();
12050 case UnqualifiedIdKind::IK_TemplateId:
12051 Diag(Name.getBeginLoc(), diag::err_using_decl_template_id)
12052 <<
SourceRange(Name.TemplateId->LAngleLoc, Name.TemplateId->RAngleLoc);
12055 case UnqualifiedIdKind::IK_DeductionGuideName:
12056 llvm_unreachable(
"cannot parse qualified deduction guide name");
12067 ? diag::err_access_decl
12068 : diag::warn_access_decl_deprecated)
12073 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
12074 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
12079 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
12086 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
12087 SS, TargetNameInfo, EllipsisLoc, AttrList,
12091 PushOnScopeChains(UD, S,
false);
12101 assert(!SS->
isInvalid() &&
"ScopeSpec is invalid");
12103 QualType EnumTy = GetTypeFromParser(
12104 getTypeName(II, IdentLoc, S, SS,
false,
12110 Diag(IdentLoc, SS && isDependentScopeSpecifier(*SS)
12111 ? diag::err_using_enum_is_dependent
12112 : diag::err_unknown_typename)
12120 Diag(IdentLoc, diag::err_using_enum_not_enum) << EnumTy;
12124 if (
auto *Def =
Enum->getDefinition())
12127 if (TSI ==
nullptr)
12131 BuildUsingEnumDeclaration(S, AS, UsingLoc, EnumLoc, IdentLoc, TSI,
Enum);
12134 PushOnScopeChains(UD, S,
false);
12149 return Context.
hasSameType(TD1->getUnderlyingType(),
12150 TD2->getUnderlyingType());
12154 if (isa<UnresolvedUsingIfExistsDecl>(D1) &&
12155 isa<UnresolvedUsingIfExistsDecl>(D2))
12186 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord())
12187 if (
auto *Using = dyn_cast<UsingDecl>(BUD)) {
12191 if (isa<EnumDecl>(OrigDC))
12198 if (OrigDC == CurContext) {
12199 Diag(Using->getLocation(),
12200 diag::err_using_decl_nested_name_specifier_is_current_class)
12201 << Using->getQualifierLoc().getSourceRange();
12203 Using->setInvalidDecl();
12207 Diag(Using->getQualifierLoc().getBeginLoc(),
12208 diag::err_using_decl_nested_name_specifier_is_not_base_class)
12210 << Using->getQualifierLoc().getSourceRange();
12212 Using->setInvalidDecl();
12217 if (
Previous.empty())
return false;
12220 if (isa<UsingShadowDecl>(Target))
12228 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
12229 bool FoundEquivalentDecl =
false;
12232 NamedDecl *D = (*I)->getUnderlyingDecl();
12236 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D) || isa<UsingEnumDecl>(D))
12239 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
12244 !isa<IndirectFieldDecl>(Target) &&
12245 !isa<UnresolvedUsingValueDecl>(Target) &&
12246 DiagnoseClassNameShadow(
12254 PrevShadow = Shadow;
12255 FoundEquivalentDecl =
true;
12256 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
12259 FoundEquivalentDecl =
true;
12266 if (FoundEquivalentDecl)
12271 if (isa<UnresolvedUsingIfExistsDecl>(Target) !=
12272 (isa_and_nonnull<UnresolvedUsingIfExistsDecl>(NonTag))) {
12273 if (!NonTag && !Tag)
12276 Diag(Target->getLocation(), diag::note_using_decl_target);
12277 Diag((NonTag ? NonTag : Tag)->getLocation(),
12278 diag::note_using_decl_conflict);
12285 switch (CheckOverload(
nullptr, FD,
Previous, OldDecl,
12290 case Ovl_NonFunction:
12299 if (CurContext->isRecord())
12307 Diag(Target->getLocation(), diag::note_using_decl_target);
12315 if (isa<TagDecl>(Target)) {
12317 if (!Tag)
return false;
12320 Diag(Target->getLocation(), diag::note_using_decl_target);
12321 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
12327 if (!NonTag)
return false;
12330 Diag(Target->getLocation(), diag::note_using_decl_target);
12340 for (
auto &B : Derived->
bases())
12341 if (B.getType()->getAsCXXRecordDecl() ==
Base)
12342 return B.isVirtual();
12343 llvm_unreachable(
"not a direct base class");
12352 if (isa<UsingShadowDecl>(Target)) {
12354 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
12358 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
12359 NonTemplateTarget = TargetTD->getTemplatedDecl();
12362 if (NonTemplateTarget && isa<CXXConstructorDecl>(NonTemplateTarget)) {
12364 bool IsVirtualBase =
12366 Using->getQualifier()->getAsRecordDecl());
12368 Context, CurContext, Using->getLocation(), Using, Orig, IsVirtualBase);
12371 Target->getDeclName(), BUD, Target);
12382 PushOnScopeChains(Shadow, S);
12384 CurContext->addDecl(Shadow);
12427 S->RemoveDecl(Shadow);
12428 IdResolver.RemoveDecl(Shadow);
12441 bool &AnyDependentBases) {
12446 CanQualType BaseType =
Base.getType()->getCanonicalTypeUnqualified();
12447 if (CanonicalDesiredBase == BaseType)
12449 if (BaseType->isDependentType())
12450 AnyDependentBases =
true;
12458 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
12460 : HasTypenameKeyword(HasTypenameKeyword),
12461 IsInstantiation(IsInstantiation), OldNNS(NNS),
12462 RequireMemberOf(RequireMemberOf) {}
12464 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
12468 if (!ND || isa<NamespaceDecl>(ND))
12478 if (RequireMemberOf) {
12479 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
12480 if (FoundRecord && FoundRecord->isInjectedClassName()) {
12495 if (!Specifier->getAsType() ||
12501 bool AnyDependentBases =
false;
12504 AnyDependentBases) &&
12505 !AnyDependentBases)
12515 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
12516 if (FoundRecord && FoundRecord->isInjectedClassName())
12520 if (isa<TypeDecl>(ND))
12521 return HasTypenameKeyword || !IsInstantiation;
12523 return !HasTypenameKeyword;
12526 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
12527 return std::make_unique<UsingValidatorCCC>(*
this);
12531 bool HasTypenameKeyword;
12532 bool IsInstantiation;
12548 if (!isDeclInScope(D, CurContext, S))
12571 bool IsUsingIfExists) {
12572 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
12574 assert(IdentLoc.
isValid() &&
"Invalid TargetName location.");
12583 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
12589 ForVisibleRedeclaration);
12596 assert(IsInstantiation &&
"no scope in non-instantiation");
12597 if (CurContext->isRecord())
12598 LookupQualifiedName(
Previous, CurContext);
12617 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
12624 Diag(UsingLoc, diag::err_using_if_exists_on_ctor);
12628 DeclContext *LookupContext = computeDeclContext(SS);
12630 if (!LookupContext || EllipsisLoc.
isValid()) {
12633 if (!LookupContext && CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword,
12634 SS, NameInfo, IdentLoc))
12637 if (HasTypenameKeyword) {
12640 UsingLoc, TypenameLoc,
12642 IdentLoc, NameInfo.
getName(),
12646 QualifierLoc, NameInfo, EllipsisLoc);
12649 CurContext->addDecl(D);
12650 ProcessDeclAttributeList(S, D, AttrList);
12654 auto Build = [&](
bool Invalid) {
12657 UsingName, HasTypenameKeyword);
12659 CurContext->addDecl(UD);
12660 ProcessDeclAttributeList(S, UD, AttrList);
12664 auto BuildInvalid = [&]{
return Build(
true); };
12665 auto BuildValid = [&]{
return Build(
false); };
12667 if (RequireCompleteDeclContext(SS, LookupContext))
12668 return BuildInvalid();
12677 if (!IsInstantiation)
12682 if (CurContext->isRecord()) {
12687 LookupQualifiedName(R, LookupContext);
12690 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
12694 if (R.
empty() && IsUsingIfExists)
12709 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
12710 CurContext->isStdNamespace() &&
12711 isa<TranslationUnitDecl>(LookupContext) &&
12712 getSourceManager().isInSystemHeader(UsingLoc))
12714 UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation, SS.
getScopeRep(),
12715 dyn_cast<CXXRecordDecl>(CurContext));
12718 CTK_ErrorRecovery)) {
12721 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
12722 << NameInfo.
getName() << LookupContext << 0
12727 NamedDecl *ND = Corrected.getCorrectionDecl();
12729 return BuildInvalid();
12732 auto *RD = dyn_cast<CXXRecordDecl>(ND);
12738 if (Corrected.WillReplaceSpecifier()) {
12740 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
12742 QualifierLoc = Builder.getWithLocInContext(Context);
12751 for (
auto *Ctor : LookupConstructors(RD))
12761 Diag(IdentLoc, diag::err_no_member)
12763 return BuildInvalid();
12768 return BuildInvalid();
12770 if (HasTypenameKeyword) {
12774 Diag(IdentLoc, diag::err_using_typename_non_type);
12776 Diag((*I)->getUnderlyingDecl()->getLocation(),
12777 diag::note_using_decl_target);
12778 return BuildInvalid();
12785 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
12787 return BuildInvalid();
12794 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
12796 return BuildInvalid();
12807 if (CheckInheritingConstructorUsingDecl(UD))
12813 if (!CheckUsingShadowDecl(UD, *I,
Previous, PrevDecl))
12814 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
12828 if (CurContext->getRedeclContext()->isRecord()) {
12832 ForVisibleRedeclaration);
12838 if (UED->getEnumDecl() == ED) {
12839 Diag(UsingLoc, diag::err_using_enum_decl_redeclaration)
12847 if (RequireCompleteEnumDecl(ED, NameLoc))
12851 EnumLoc, NameLoc, EnumType);
12853 CurContext->addDecl(UD);
12865 ForVisibleRedeclaration);
12869 if (!CheckUsingShadowDecl(UD, EC,
Previous, PrevDecl))
12870 BuildUsingShadowDecl(S, UD, EC, PrevDecl);
12878 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
12879 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
12880 isa<UsingPackDecl>(InstantiatedFrom));
12884 UPD->setAccess(InstantiatedFrom->
getAccess());
12885 CurContext->addDecl(UPD);
12891 assert(!UD->
hasTypename() &&
"expecting a constructor name");
12894 assert(SourceType &&
12895 "Using decl naming constructor doesn't have type in scope spec.");
12899 bool AnyDependentBases =
false;
12901 AnyDependentBases);
12902 if (!
Base && !AnyDependentBases) {
12904 diag::err_using_decl_constructor_not_in_direct_base)
12906 <<
QualType(SourceType, 0) << TargetClass;
12912 Base->setInheritConstructors();
12921 bool HasTypenameKeyword,
12934 if (!CurContext->getRedeclContext()->isRecord()) {
12940 if (Qual->
isDependent() && !HasTypenameKeyword) {
12941 for (
auto *D : Prev) {
12942 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
12943 bool OldCouldBeEnumerator =
12946 OldCouldBeEnumerator ? diag::err_redefinition
12947 : diag::err_redefinition_different_kind)
12948 << Prev.getLookupName();
12964 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
12965 DTypename = UD->hasTypename();
12966 DQual = UD->getQualifier();
12968 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
12970 DQual = UD->getQualifier();
12972 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
12974 DQual = UD->getQualifier();
12979 if (HasTypenameKeyword != DTypename)
continue;
12987 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
13007 DeclContext *NamedContext = computeDeclContext(SS);
13008 assert(
bool(NamedContext) == (R || UD) && !(R && UD) &&
13009 "resolvable context must have exactly one set of decls");
13013 bool Cxx20Enumerator =
false;
13014 if (NamedContext) {
13021 Cxx20Enumerator = getLangOpts().CPlusPlus20;
13023 if (
auto *ED = dyn_cast<EnumDecl>(NamedContext)) {
13027 if (EC && R && ED->isScoped())
13030 ? diag::warn_cxx17_compat_using_decl_scoped_enumerator
13031 : diag::ext_using_decl_scoped_enumerator)
13035 NamedContext = ED->getDeclContext();
13039 if (!CurContext->isRecord()) {
13055 ? diag::warn_cxx17_compat_using_decl_class_member_enumerator
13056 : diag::err_using_decl_can_not_refer_to_class_member)
13059 if (Cxx20Enumerator)
13062 auto *RD = NamedContext
13065 if (RD && !RequireCompleteDeclContext(
const_cast<CXXScopeSpec &
>(SS), RD)) {
13074 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
13082 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
13098 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
13113 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
13114 << (getLangOpts().CPlusPlus11 ? 4 : 3)
13123 if (!NamedContext) {
13139 ? diag::warn_cxx17_compat_using_decl_non_member_enumerator
13140 : diag::err_using_decl_nested_name_specifier_is_not_class)
13143 if (Cxx20Enumerator)
13150 RequireCompleteDeclContext(
const_cast<CXXScopeSpec&
>(SS), NamedContext))
13160 cast<CXXRecordDecl>(NamedContext))) {
13162 if (Cxx20Enumerator) {
13163 Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
13168 if (CurContext == NamedContext) {
13170 diag::err_using_decl_nested_name_specifier_is_current_class)
13172 return !getLangOpts().CPlusPlus20;
13175 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
13177 diag::err_using_decl_nested_name_specifier_is_not_base_class)
13202 Bases.insert(
Base);
13207 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
13213 return !Bases.count(
Base);
13218 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
13219 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
13223 diag::err_using_decl_nested_name_specifier_is_not_base_class)
13237 while (S->isTemplateParamScope())
13238 S = S->getParent();
13240 "got alias-declaration outside of declaration scope");
13242 if (
Type.isInvalid())
13248 GetTypeFromParser(
Type.get(), &TInfo);
13250 if (DiagnoseClassNameShadow(CurContext, NameInfo))
13253 if (DiagnoseUnexpandedParameterPack(Name.StartLocation, TInfo,
13254 UPPC_DeclarationType)) {
13261 TemplateParamLists.size()
13262 ? forRedeclarationInCurContext()
13263 : ForVisibleRedeclaration);
13268 Previous.getFoundDecl()->isTemplateParameter()) {
13269 DiagnoseTemplateParameterShadow(Name.StartLocation,
Previous.getFoundDecl());
13273 assert(Name.getKind() == UnqualifiedIdKind::IK_Identifier &&
13274 "name in alias declaration must be an identifier");
13276 Name.StartLocation,
13277 Name.Identifier, TInfo);
13284 ProcessDeclAttributeList(S, NewTD, AttrList);
13285 AddPragmaAttributes(S, NewTD);
13287 CheckTypedefForVariablyModifiedType(S, NewTD);
13290 bool Redeclaration =
false;
13293 if (TemplateParamLists.size()) {
13297 if (TemplateParamLists.size() != 1) {
13298 Diag(UsingLoc, diag::err_alias_template_extra_headers)
13299 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
13300 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
13305 if (CheckTemplateDeclScope(S, TemplateParams))
13309 FilterLookupForScope(
Previous, CurContext, S,
false,
13312 Redeclaration =
true;
13316 Diag(UsingLoc, diag::err_redefinition_different_kind)
13317 << Name.Identifier;
13327 if (TemplateParameterListsAreEqual(TemplateParams,
13330 TPL_TemplateMatch))
13331 OldTemplateParams =
13353 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
13354 TPC_TypeAliasTemplate))
13359 Name.Identifier, TemplateParams,
13367 else if (OldDecl) {
13369 CheckRedeclarationInModule(NewDecl, OldDecl);
13374 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
13375 setTagNameForLinkagePurposes(TD, NewTD);
13376 handleTagNumbering(TD, S);
13378 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
13382 PushOnScopeChains(NewND, S);
13383 ActOnDocumentableDecl(NewND);
13394 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
13395 LookupParsedName(R, S, &SS);
13402 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
13410 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
13411 ForVisibleRedeclaration);
13412 LookupName(PrevR, S);
13416 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
13421 FilterLookupForScope(PrevR, CurContext, S,
false,
13433 }
else if (isVisible(PrevDecl)) {
13434 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
13436 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
13437 << AD->getNamespace();
13440 }
else if (isVisible(PrevDecl)) {
13442 ? diag::err_redefinition
13443 : diag::err_redefinition_different_kind;
13444 Diag(AliasLoc, DiagID) << Alias;
13451 DiagnoseUseOfDecl(ND, IdentLoc);
13465struct SpecialMemberExceptionSpecInfo
13466 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
13474 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
13479 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
13482 void visitSubobjectCall(Subobject Subobj,
13488 auto *RT =
Base->getType()->getAs<RecordType>();
13494 if (
auto *BaseCtor = SMOR.
getMethod()) {
13495 visitSubobjectCall(
Base, BaseCtor);
13499 visitClassSubobject(BaseClass,
Base, 0);
13503bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
13516 ->
getAs<RecordType>()) {
13517 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
13523void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
13527 bool IsMutable =
Field &&
Field->isMutable();
13528 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
13531void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
13536 ExceptSpec.
CalledDecl(getSubobjectLoc(Subobj), MD);
13540 llvm::APSInt Result;
13542 ExplicitSpec.
getExpr(), Context.
BoolTy, Result, CCEK_ExplicitBool);
13545 ExplicitSpec.
setKind(Result.getBoolValue()
13546 ? ExplicitSpecKind::ResolvedTrue
13547 : ExplicitSpecKind::ResolvedFalse);
13550 ExplicitSpec.
setKind(ExplicitSpecKind::Unresolved);
13557 tryResolveExplicitSpecifier(ES);
13565 ComputingExceptionSpec CES(S, MD, Loc);
13572 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
13574 return Info.ExceptSpec;
13581 diag::err_exception_spec_incomplete_type))
13582 return Info.ExceptSpec;
13599 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
13600 : Info.VisitAllBases);
13602 return Info.ExceptSpec;
13607struct DeclaringSpecialMember {
13611 bool WasAlreadyBeingDeclared;
13614 : S(S), D(RD, CSM), SavedContext(S, RD) {
13616 if (WasAlreadyBeingDeclared)
13623 Sema::CodeSynthesisContext Ctx;
13624 Ctx.Kind = Sema::CodeSynthesisContext::DeclaringSpecialMember;
13631 Ctx.PointOfInstantiation = RD->getLocation();
13633 Ctx.SpecialMember = CSM;
13634 S.pushCodeSynthesisContext(Ctx);
13637 ~DeclaringSpecialMember() {
13638 if (!WasAlreadyBeingDeclared) {
13645 bool isAlreadyBeingDeclared()
const {
13646 return WasAlreadyBeingDeclared;
13656 ForExternalRedeclaration);
13663 CheckFunctionDeclaration(S, FD, R,
false,
13667void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
13673 LangAS AS = getDefaultCXXMethodAddrSpace();
13674 if (AS != LangAS::Default) {
13684 if (inTemplateInstantiation() &&
13685 cast<CXXRecordDecl>(SpecialMem->
getParent())->isLambda()) {
13701 "Should not build implicit default constructor!");
13703 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
13704 if (DSM.isAlreadyBeingDeclared())
13708 CXXDefaultConstructor,
13719 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
13721 getCurFPFeatures().isFPConstrained(),
13723 Constexpr ? ConstexprSpecKind::Constexpr
13724 : ConstexprSpecKind::Unspecified);
13728 setupImplicitSpecialMemberType(DefaultCon, Context.
VoidTy, std::nullopt);
13730 if (getLangOpts().
CUDA)
13731 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
13741 ++getASTContext().NumImplicitDefaultConstructorsDeclared;
13743 Scope *S = getScopeForContext(ClassDecl);
13744 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
13746 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
13747 SetDeclDeleted(DefaultCon, ClassLoc);
13750 PushOnScopeChains(DefaultCon, S,
false);
13751 ClassDecl->
addDecl(DefaultCon);
13758 assert((Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
13759 !Constructor->doesThisDeclarationHaveABody() &&
13760 !Constructor->isDeleted()) &&
13761 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
13762 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
13766 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
13772 ResolveExceptionSpec(CurrentLocation,
13774 MarkVTableUsed(CurrentLocation, ClassDecl);
13777 Scope.addContextNote(CurrentLocation);
13779 if (SetCtorInitializers(Constructor,
false)) {
13780 Constructor->setInvalidDecl();
13785 ? Constructor->getEndLoc()
13786 : Constructor->getLocation();
13787 Constructor->setBody(
new (Context)
CompoundStmt(Loc));
13788 Constructor->markUsed(Context);
13791 L->CompletedImplicitDefinition(Constructor);
13794 DiagnoseUninitializedFields(*
this, Constructor);
13799 CheckDelayedMemberExceptionSpecs();
13820 ->getInheritedConstructor()
13838 false, BaseCtor, &ICI);
13841 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
13855 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
13865 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
13872 ParamDecls.push_back(PD);
13877 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
13880 Derived->
addDecl(DerivedCtor);
13882 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
13883 SetDeclDeleted(DerivedCtor, UsingLoc);
13885 return DerivedCtor;
13891 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
13898 assert(Constructor->getInheritedConstructor() &&
13899 !Constructor->doesThisDeclarationHaveABody() &&
13900 !Constructor->isDeleted());
13901 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
13910 ResolveExceptionSpec(CurrentLocation,
13912 MarkVTableUsed(CurrentLocation, ClassDecl);
13915 Scope.addContextNote(CurrentLocation);
13918 Constructor->getInheritedConstructor().getShadowDecl();
13920 Constructor->getInheritedConstructor().getConstructor();
13934 for (
bool VBase : {
false,
true}) {
13936 if (B.isVirtual() != VBase)
13939 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
13944 if (!BaseCtor.first)
13947 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
13949 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
13953 Context, TInfo, VBase, InitLoc, Init.get(), InitLoc,
13961 if (SetCtorInitializers(Constructor,
false, Inits)) {
13962 Constructor->setInvalidDecl();
13966 Constructor->setBody(
new (Context)
CompoundStmt(InitLoc));
13967 Constructor->markUsed(Context);
13970 L->CompletedImplicitDefinition(Constructor);
13973 DiagnoseUninitializedFields(*
this, Constructor);
13983 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
13984 if (DSM.isAlreadyBeingDeclared())
13999 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
14000 getCurFPFeatures().isFPConstrained(),
14003 Constexpr ? ConstexprSpecKind::Constexpr
14004 : ConstexprSpecKind::Unspecified);
14006 Destructor->setDefaulted();
14008 setupImplicitSpecialMemberType(Destructor, Context.
VoidTy, std::nullopt);
14010 if (getLangOpts().
CUDA)
14011 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
14019 Destructor->setTrivialForCall(ClassDecl->
hasAttr<TrivialABIAttr>() ||
14023 ++getASTContext().NumImplicitDestructorsDeclared;
14025 Scope *S = getScopeForContext(ClassDecl);
14026 CheckImplicitSpecialMemberDeclaration(S, Destructor);
14032 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
14033 SetDeclDeleted(Destructor, ClassLoc);
14037 PushOnScopeChains(Destructor, S,
false);
14038 ClassDecl->
addDecl(Destructor);
14045 assert((Destructor->isDefaulted() &&
14046 !Destructor->doesThisDeclarationHaveABody() &&
14047 !Destructor->isDeleted()) &&
14048 "DefineImplicitDestructor - call it for implicit default dtor");
14049 if (Destructor->willHaveBody() || Destructor->isInvalidDecl())
14053 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
14059 ResolveExceptionSpec(CurrentLocation,
14061 MarkVTableUsed(CurrentLocation, ClassDecl);
14064 Scope.addContextNote(CurrentLocation);
14066 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
14067 Destructor->getParent());
14069 if (CheckDestructor(Destructor)) {
14070 Destructor->setInvalidDecl();
14075 ? Destructor->getEndLoc()
14076 : Destructor->getLocation();
14078 Destructor->markUsed(Context);
14081 L->CompletedImplicitDefinition(Destructor);
14087 if (Destructor->isInvalidDecl())
14092 "implicit complete dtors unneeded outside MS ABI");
14094 "complete dtor only exists for classes with vbases");
14099 Scope.addContextNote(CurrentLocation);
14101 MarkVirtualBaseDestructorsReferenced(Destructor->getLocation(), ClassDecl);
14108 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
14109 if (Record->isInvalidDecl()) {
14110 DelayedOverridingExceptionSpecChecks.clear();
14111 DelayedEquivalentExceptionSpecChecks.clear();
14119 referenceDLLExportedClassMethods();
14121 if (!DelayedDllExportMemberFunctions.empty()) {
14123 std::swap(DelayedDllExportMemberFunctions, WorkList);
14130 if (M->getParent()->getTemplateSpecializationKind() !=
14132 ActOnFinishInlineFunctionDef(M);
14138 if (!DelayedDllExportClasses.empty()) {
14142 std::swap(DelayedDllExportClasses, WorkList);
14150 "adjusting dtor exception specs was introduced in c++11");
14152 if (Destructor->isDependentContext())
14160 if (DtorType->hasExceptionSpec())
14169 Destructor->setType(
14184 ExprBuilder(
const ExprBuilder&) =
delete;
14185 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
14188 static Expr *assertNotNull(
Expr *E) {
14189 assert(E &&
"Expression construction must not fail.");
14195 virtual ~ExprBuilder() {}
14200class RefBuilder:
public ExprBuilder {
14210 : Var(Var), VarType(VarType) {}
14213class ThisBuilder:
public ExprBuilder {
14220class CastBuilder:
public ExprBuilder {
14221 const ExprBuilder &Builder;
14229 CK_UncheckedDerivedToBase, Kind,
14235 : Builder(Builder),
Type(
Type), Kind(Kind), Path(Path) {}
14238class DerefBuilder:
public ExprBuilder {
14239 const ExprBuilder &Builder;
14243 return assertNotNull(
14247 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14250class MemberBuilder:
public ExprBuilder {
14251 const ExprBuilder &Builder;
14261 nullptr, MemberLookup,
nullptr,
nullptr).get());
14264 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
14266 : Builder(Builder),
Type(
Type), IsArrow(IsArrow),
14267 MemberLookup(MemberLookup) {}
14270class MoveCastBuilder:
public ExprBuilder {
14271 const ExprBuilder &Builder;
14275 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
14278 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14281class LvalueConvBuilder:
public ExprBuilder {
14282 const ExprBuilder &Builder;
14286 return assertNotNull(
14290 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14293class SubscriptBuilder:
public ExprBuilder {
14294 const ExprBuilder &
Base;
14295 const ExprBuilder &Index;
14300 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
14303 SubscriptBuilder(
const ExprBuilder &
Base,
const ExprBuilder &Index)
14315 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
14324 Expr *From = FromB.build(S, Loc);
14328 Expr *To = ToB.build(S, Loc);
14333 const Type *E = T->getBaseElementTypeUnsafe();
14334 bool NeedsCollectableMemCpy =
14336 E->
castAs<RecordType>()->getDecl()->hasObjectMember();
14339 StringRef MemCpyName = NeedsCollectableMemCpy ?
14340 "__builtin_objc_memmove_collectable" :
14341 "__builtin_memcpy";
14354 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
14356 Expr *CallArgs[] = {
14360 Loc, CallArgs, Loc);
14362 assert(!Call.isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
14363 return Call.getAs<
Stmt>();
14395 const ExprBuilder &To,
const ExprBuilder &From,
14396 bool CopyingBaseSubobject,
bool Copying,
14397 unsigned Depth = 0) {
14412 if (
const RecordType *RecordTy = T->getAs<RecordType>()) {
14428 if (Method->isCopyAssignmentOperator() ||
14429 (!Copying && Method->isMoveAssignmentOperator()))
14448 if (CopyingBaseSubobject) {
14479 Expr *FromInst = From.build(S, Loc);
14482 Loc, FromInst, Loc);
14483 if (Call.isInvalid())
14502 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
14503 if (Assignment.isInvalid())
14522 llvm::raw_svector_ostream OS(Str);
14523 OS <<
"__i" << Depth;
14527 IterationVarName, SizeType,
14536 RefBuilder IterationVarRef(IterationVar, SizeType);
14537 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
14543 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
14544 MoveCastBuilder FromIndexMove(FromIndexCopy);
14545 const ExprBuilder *FromIndex;
14547 FromIndex = &FromIndexCopy;
14549 FromIndex = &FromIndexMove;
14551 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
14556 ToIndex, *FromIndex, CopyingBaseSubobject,
14557 Copying, Depth + 1);
14559 if (
Copy.isInvalid() || !
Copy.get())
14566 S.
Context, IterationVarRefRVal.build(S, Loc),
14580 Loc, Loc, InitStmt,
14581 S.
ActOnCondition(
nullptr, Loc, Comparison, Sema::ConditionKind::Boolean),
14587 const ExprBuilder &To,
const ExprBuilder &From,
14588 bool CopyingBaseSubobject,
bool Copying) {
14590 if (T->isArrayType() && !T.isConstQualified() && !T.isVolatileQualified() &&
14591 T.isTriviallyCopyableType(S.
Context))
14595 CopyingBaseSubobject,
14600 if (!Result.isInvalid() && !Result.get())
14613 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
14614 if (DSM.isAlreadyBeingDeclared())
14619 LangAS AS = getDefaultCXXMethodAddrSpace();
14620 if (AS != LangAS::Default)
14625 ArgType = ArgType.withConst();
14639 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
14641 getCurFPFeatures().isFPConstrained(),
14643 Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified,
14649 setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
14651 if (getLangOpts().
CUDA)
14652 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
14659 ClassLoc, ClassLoc,
14667 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
14671 ++getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;
14673 Scope *S = getScopeForContext(ClassDecl);
14674 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
14676 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment)) {
14678 SetDeclDeleted(CopyAssignment, ClassLoc);
14682 PushOnScopeChains(CopyAssignment, S,
false);
14683 ClassDecl->
addDecl(CopyAssignment);
14685 return CopyAssignment;
14699 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
14702 for (
auto *I : RD->
ctors()) {
14703 if (I->isCopyConstructor()) {
14704 UserDeclaredOperation = I;
14708 assert(UserDeclaredOperation);
14709 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
14712 for (
auto *I : RD->
methods()) {
14713 if (I->isCopyAssignmentOperator()) {
14714 UserDeclaredOperation = I;
14718 assert(UserDeclaredOperation);
14721 if (UserDeclaredOperation) {
14722 bool UDOIsUserProvided = UserDeclaredOperation->
isUserProvided();
14726 (UDOIsUserProvided && UDOIsDestructor)
14727 ? diag::warn_deprecated_copy_with_user_provided_dtor
14728 : (UDOIsUserProvided && !UDOIsDestructor)
14729 ? diag::warn_deprecated_copy_with_user_provided_copy
14730 : (!UDOIsUserProvided && UDOIsDestructor)
14731 ? diag::warn_deprecated_copy_with_dtor
14732 : diag::warn_deprecated_copy;
14734 << RD << IsCopyAssignment;
14745 "DefineImplicitCopyAssignment called for wrong function");
14759 ResolveExceptionSpec(CurrentLocation,
14763 Scope.addContextNote(CurrentLocation);
14785 Qualifiers OtherQuals = Other->getType().getQualifiers();
14786 QualType OtherRefType = Other->getType();
14799 RefBuilder OtherRef(Other, OtherRefType);
14806 for (
auto &
Base : ClassDecl->
bases()) {
14809 QualType BaseType =
Base.getType().getUnqualifiedType();
14810 if (!BaseType->isRecordType()) {
14816 BasePath.push_back(&
Base);
14820 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
14824 DerefBuilder DerefThis(This);
14825 CastBuilder To(DerefThis,
14835 if (
Copy.isInvalid()) {
14841 Statements.push_back(
Copy.getAs<
Expr>());
14845 for (
auto *Field : ClassDecl->
fields()) {
14848 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
14851 if (Field->isInvalidDecl()) {
14857 if (Field->getType()->isReferenceType()) {
14858 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
14859 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
14860 Diag(Field->getLocation(), diag::note_declared_at);
14867 if (!BaseType->getAs<RecordType>() && BaseType.isConstQualified()) {
14868 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
14869 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
14870 Diag(Field->getLocation(), diag::note_declared_at);
14876 if (Field->isZeroLengthBitField(Context))
14879 QualType FieldType = Field->getType().getNonReferenceType();
14882 "Incomplete array type is not valid");
14888 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
14893 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
14895 MemberBuilder To(This, getCurrentThisType(), !LangOpts.HLSL,
14903 if (
Copy.isInvalid()) {
14909 Statements.push_back(
Copy.getAs<
Stmt>());
14914 Expr *ThisExpr =
nullptr;
14915 if (!LangOpts.HLSL) {
14917 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
14918 ThisExpr = ThisObj.
get();
14920 ThisExpr = This.build(*
this, Loc);
14923 StmtResult Return = BuildReturnStmt(Loc, ThisExpr);
14927 Statements.push_back(Return.
getAs<
Stmt>());
14938 Body = ActOnCompoundStmt(Loc, Loc, Statements,
14940 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
14943 CopyAssignOperator->
markUsed(Context);
14946 L->CompletedImplicitDefinition(CopyAssignOperator);
14953 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
14954 if (DSM.isAlreadyBeingDeclared())
14962 LangAS AS = getDefaultCXXMethodAddrSpace();
14963 if (AS != LangAS::Default)
14978 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
14980 getCurFPFeatures().isFPConstrained(),
14982 Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified,
14988 setupImplicitSpecialMemberType(MoveAssignment, RetType, ArgType);
14990 if (getLangOpts().
CUDA)
14991 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
14998 ClassLoc, ClassLoc,
15006 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
15010 ++getASTContext().NumImplicitMoveAssignmentOperatorsDeclared;
15012 Scope *S = getScopeForContext(ClassDecl);
15013 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
15015 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
15017 SetDeclDeleted(MoveAssignment, ClassLoc);
15021 PushOnScopeChains(MoveAssignment, S,
false);
15022 ClassDecl->
addDecl(MoveAssignment);
15024 return MoveAssignment;
15032 assert(!Class->isDependentContext() &&
"should not define dependent move");
15038 if (Class->getNumVBases() == 0 || Class->hasTrivialMoveAssignment() ||
15039 Class->getNumBases() < 2)
15043 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
15046 for (
auto &BI : Class->bases()) {
15047 Worklist.push_back(&BI);
15048 while (!Worklist.empty()) {
15054 if (!
Base->hasNonTrivialMoveAssignment())
15079 VBases.insert(std::make_pair(
Base->getCanonicalDecl(), &BI))
15081 if (Existing && Existing != &BI) {
15082 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
15085 << (
Base->getCanonicalDecl() ==
15088 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
15089 << (
Base->getCanonicalDecl() ==
15090 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
15094 Existing =
nullptr;
15104 llvm::append_range(Worklist, llvm::make_pointer_range(
Base->bases()));
15117 "DefineImplicitMoveAssignment called for wrong function");
15143 ResolveExceptionSpec(CurrentLocation,
15147 Scope.addContextNote(CurrentLocation);
15163 RefBuilder OtherRef(Other, OtherRefType);
15165 MoveCastBuilder MoveOther(OtherRef);
15172 for (
auto &
Base : ClassDecl->
bases()) {
15183 QualType BaseType =
Base.getType().getUnqualifiedType();
15184 if (!BaseType->isRecordType()) {
15190 BasePath.push_back(&
Base);
15194 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
15197 DerefBuilder DerefThis(This);
15200 CastBuilder To(DerefThis,
15210 if (Move.isInvalid()) {
15216 Statements.push_back(Move.getAs<
Expr>());
15220 for (
auto *Field : ClassDecl->
fields()) {
15223 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
15226 if (Field->isInvalidDecl()) {
15232 if (Field->getType()->isReferenceType()) {
15233 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15234 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
15235 Diag(Field->getLocation(), diag::note_declared_at);
15242 if (!BaseType->getAs<RecordType>() && BaseType.isConstQualified()) {
15243 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
15244 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
15245 Diag(Field->getLocation(), diag::note_declared_at);
15251 if (Field->isZeroLengthBitField(Context))
15254 QualType FieldType = Field->getType().getNonReferenceType();
15257 "Incomplete array type is not valid");
15262 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
15266 MemberBuilder From(MoveOther, OtherRefType,
15267 false, MemberLookup);
15268 MemberBuilder To(This, getCurrentThisType(),
15269 true, MemberLookup);
15271 assert(!From.build(*
this, Loc)->isLValue() &&
15272 "Member reference with rvalue base must be rvalue except for reference "
15273 "members, which aren't allowed for move assignment.");
15280 if (Move.isInvalid()) {
15286 Statements.push_back(Move.getAs<
Stmt>());
15292 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
15298 Statements.push_back(Return.
getAs<
Stmt>());
15309 Body = ActOnCompoundStmt(Loc, Loc, Statements,
15311 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
15314 MoveAssignOperator->
markUsed(Context);
15317 L->CompletedImplicitDefinition(MoveAssignOperator);
15328 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
15329 if (DSM.isAlreadyBeingDeclared())
15337 ArgType = ArgType.withConst();
15339 LangAS AS = getDefaultCXXMethodAddrSpace();
15340 if (AS != LangAS::Default)
15346 CXXCopyConstructor,
15358 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
15362 Constexpr ? ConstexprSpecKind::Constexpr
15363 : ConstexprSpecKind::Unspecified);
15367 setupImplicitSpecialMemberType(CopyConstructor, Context.
VoidTy, ArgType);
15369 if (getLangOpts().
CUDA)
15370 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
15379 if (inTemplateInstantiation() && ClassDecl->
isLambda())
15391 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
15395 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15397 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
15398 TAH_ConsiderTrivialABI)
15402 ++getASTContext().NumImplicitCopyConstructorsDeclared;
15404 Scope *S = getScopeForContext(ClassDecl);
15405 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
15407 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
15409 SetDeclDeleted(CopyConstructor, ClassLoc);
15413 PushOnScopeChains(CopyConstructor, S,
false);
15414 ClassDecl->
addDecl(CopyConstructor);
15416 return CopyConstructor;
15425 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
15430 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
15436 ResolveExceptionSpec(CurrentLocation,
15438 MarkVTableUsed(CurrentLocation, ClassDecl);
15441 Scope.addContextNote(CurrentLocation);
15450 if (SetCtorInitializers(CopyConstructor,
false)) {
15458 ActOnCompoundStmt(Loc, Loc, std::nullopt,
false)
15460 CopyConstructor->
markUsed(Context);
15464 L->CompletedImplicitDefinition(CopyConstructor);
15472 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
15473 if (DSM.isAlreadyBeingDeclared())
15480 LangAS AS = getDefaultCXXMethodAddrSpace();
15481 if (AS != LangAS::Default)
15486 CXXMoveConstructor,
15499 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
15503 Constexpr ? ConstexprSpecKind::Constexpr
15504 : ConstexprSpecKind::Unspecified);
15508 setupImplicitSpecialMemberType(MoveConstructor, Context.
VoidTy, ArgType);
15510 if (getLangOpts().
CUDA)
15511 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
15518 ClassLoc, ClassLoc,
15526 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
15530 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15532 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
15533 TAH_ConsiderTrivialABI)
15537 ++getASTContext().NumImplicitMoveConstructorsDeclared;
15539 Scope *S = getScopeForContext(ClassDecl);
15540 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
15542 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
15544 SetDeclDeleted(MoveConstructor, ClassLoc);
15548 PushOnScopeChains(MoveConstructor, S,
false);
15549 ClassDecl->
addDecl(MoveConstructor);
15551 return MoveConstructor;
15560 "DefineImplicitMoveConstructor - call it for implicit move ctor");
15565 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
15571 ResolveExceptionSpec(CurrentLocation,
15573 MarkVTableUsed(CurrentLocation, ClassDecl);
15576 Scope.addContextNote(CurrentLocation);
15578 if (SetCtorInitializers(MoveConstructor,
false)) {
15586 ActOnCompoundStmt(Loc, Loc, std::nullopt,
false)
15588 MoveConstructor->
markUsed(Context);
15592 L->CompletedImplicitDefinition(MoveConstructor);
15616 CallOp = InstantiateFunctionDeclaration(
15621 if (CallOp != Invoker) {
15622 Invoker = InstantiateFunctionDeclaration(
15638 MarkFunctionReferenced(CurrentLocation, CallOp);
15640 if (Invoker != CallOp) {
15653 assert(FunctionRef &&
"Can't refer to __invoke function?");
15654 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).get();
15661 L->CompletedImplicitDefinition(Conv);
15662 if (Invoker != CallOp)
15663 L->CompletedImplicitDefinition(Invoker);
15674 Expr *This = ActOnCXXThis(CurrentLocation).get();
15675 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
15677 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
15685 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
15687 Context, BuildBlock.
get()->
getType(), CK_CopyAndAutoreleaseBlockObject,
15691 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
15700 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
15706 Stmt *ReturnS = Return.
get();
15713 L->CompletedImplicitDefinition(Conv);
15720 switch (Args.size()) {
15725 if (!Args[1]->isDefaultArgument())
15730 return !Args[0]->isDefaultArgument();
15741 bool HadMultipleCandidates,
15742 bool IsListInitialization,
15743 bool IsStdInitListInitialization,
15744 bool RequiresZeroInit,
15745 unsigned ConstructKind,
15747 bool Elidable =
false;
15766 Expr *SubExpr = ExprArgs[0];
15775 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
15776 FoundDecl, Constructor,
15777 Elidable, ExprArgs, HadMultipleCandidates,
15778 IsListInitialization,
15779 IsStdInitListInitialization, RequiresZeroInit,
15780 ConstructKind, ParenRange);
15789 bool HadMultipleCandidates,
15790 bool IsListInitialization,
15791 bool IsStdInitListInitialization,
15792 bool RequiresZeroInit,
15793 unsigned ConstructKind,
15795 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
15796 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
15800 if (DiagnoseUseOfOverloadedDecl(Constructor, ConstructLoc))
15804 return BuildCXXConstructExpr(
15805 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
15806 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
15807 RequiresZeroInit, ConstructKind, ParenRange);
15817 bool HadMultipleCandidates,
15818 bool IsListInitialization,
15819 bool IsStdInitListInitialization,
15820 bool RequiresZeroInit,
15821 unsigned ConstructKind,
15824 Constructor->getParent(),
15826 "given constructor for wrong type");
15827 MarkFunctionReferenced(ConstructLoc, Constructor);
15828 if (getLangOpts().
CUDA && !CheckCUDACall(ConstructLoc, Constructor))
15831 return CheckForImmediateInvocation(
15833 Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs,
15834 HadMultipleCandidates, IsListInitialization,
15835 IsStdInitListInitialization, RequiresZeroInit,
15866 MarkFunctionReferenced(VD->
getLocation(), Destructor);
15867 CheckDestructorAccess(VD->
getLocation(), Destructor,
15868 PDiag(diag::err_access_dtor_var)
15870 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
15873 if (Destructor->isTrivial())
return;
15877 if (Destructor->isConstexpr()) {
15878 bool HasConstantInit =
false;
15885 diag::err_constexpr_var_requires_const_destruction) << VD;
15886 for (
unsigned I = 0,
N = Notes.size(); I !=
N; ++I)
15887 Diag(Notes[I].first, Notes[I].second);
15912 bool AllowExplicit,
15913 bool IsListInitialization) {
15915 unsigned NumArgs = ArgsPtr.size();
15916 Expr **Args = ArgsPtr.data();
15922 if (NumArgs < NumParams)
15923 ConvertedArgs.reserve(NumParams);
15925 ConvertedArgs.reserve(NumArgs);
15928 Proto->isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
15930 bool Invalid = GatherArgumentsForCall(
15931 Loc, Constructor, Proto, 0,
llvm::ArrayRef(Args, NumArgs), AllArgs,
15932 CallType, AllowExplicit, IsListInitialization);
15933 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
15935 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
15937 CheckConstructorCall(Constructor, DeclInitType,
15948 if (isa<NamespaceDecl>(DC)) {
15950 diag::err_operator_new_delete_declared_in_namespace)
15954 if (isa<TranslationUnitDecl>(DC) &&
15957 diag::err_operator_new_delete_declared_static)
15967 Qualifiers PtrQuals = PtrTy->getPointeeType().getQualifiers();
15970 PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals)));
15977 unsigned DependentParamTypeDiag,
15978 unsigned InvalidParamTypeDiag) {
15996 return SemaRef.
Diag(
15999 ? diag::err_operator_new_delete_dependent_result_type
16000 : diag::err_operator_new_delete_invalid_result_type)
16007 diag::err_operator_new_delete_template_too_few_parameters)
16013 diag::err_operator_new_delete_too_few_parameters)
16020 if (
const auto *PtrTy =
16025 ExpectedFirstParamType =
16031 ExpectedFirstParamType) {
16036 ? DependentParamTypeDiag
16037 : InvalidParamTypeDiag)
16038 << FnDecl->
getDeclName() << ExpectedFirstParamType;
16061 diag::err_operator_new_dependent_param_type,
16062 diag::err_operator_new_param_type))
16069 diag::err_operator_new_default_arg)
16084 auto *MD = dyn_cast<CXXMethodDecl>(FnDecl);
16099 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
16100 diag::err_operator_delete_dependent_param_type,
16101 diag::err_operator_delete_param_type))
16110 diag::err_destroying_operator_delete_not_usual);
16122 "Expected an overloaded operator declaration");
16132 if (Op == OO_Delete || Op == OO_Array_Delete)
16135 if (Op == OO_New || Op == OO_Array_New)
16145 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
16146 if (MethodDecl->isStatic()) {
16147 if (Op == OO_Call || Op == OO_Subscript)
16149 (LangOpts.CPlusPlus23
16150 ? diag::warn_cxx20_compat_operator_overload_static
16151 : diag::ext_operator_overload_static))
16154 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_static)
16158 bool ClassOrEnumParam =
false;
16160 QualType ParamType = Param->getType().getNonReferenceType();
16163 ClassOrEnumParam =
true;
16168 if (!ClassOrEnumParam)
16170 diag::err_operator_overload_needs_class_or_enum)
16180 if (Op != OO_Call) {
16183 if (Param->hasDefaultArg()) {
16184 FirstDefaultedParam = Param;
16188 if (FirstDefaultedParam) {
16189 if (Op == OO_Subscript) {
16191 ? diag::ext_subscript_overload
16192 : diag::error_subscript_overload)
16197 diag::err_operator_overload_default_arg)
16205 {
false,
false,
false }
16206#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
16207 , { Unary, Binary, MemberOnly }
16208#include "clang/Basic/OperatorKinds.def"
16211 bool CanBeUnaryOperator = OperatorUses[Op][0];
16212 bool CanBeBinaryOperator = OperatorUses[Op][1];
16213 bool MustBeMemberOperator = OperatorUses[Op][2];
16221 if (Op != OO_Call && Op != OO_Subscript &&
16222 ((NumParams == 1 && !CanBeUnaryOperator) ||
16223 (NumParams == 2 && !CanBeBinaryOperator) || (NumParams < 1) ||
16224 (NumParams > 2))) {
16226 unsigned ErrorKind;
16227 if (CanBeUnaryOperator && CanBeBinaryOperator) {
16229 }
else if (CanBeUnaryOperator) {
16232 assert(CanBeBinaryOperator &&
16233 "All non-call overloaded operators are unary or binary!");
16236 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
16237 << FnDecl->
getDeclName() << NumParams << ErrorKind;
16240 if (Op == OO_Subscript && NumParams != 2) {
16242 ? diag::ext_subscript_overload
16243 : diag::error_subscript_overload)
16244 << FnDecl->
getDeclName() << (NumParams == 1 ? 0 : 2);
16249 if (Op != OO_Call &&
16251 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
16256 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
16258 diag::err_operator_overload_must_be_member)
16272 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
16279 diag::err_operator_overload_post_incdec_must_be_int)
16280 << LastParam->
getType() << (Op == OO_MinusMinus);
16292 if (TemplateParams->
size() == 1) {
16294 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(0));
16308 if (SemaRef.
getLangOpts().CPlusPlus20 && PmDecl &&
16311 PmDecl->
getType()->
getAs<DeducedTemplateSpecializationType>()))
16313 }
else if (TemplateParams->
size() == 2) {
16315 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
getParam(0));
16317 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(1));
16323 const TemplateTypeParmType *TArgs =
16325 if (TArgs && TArgs->getDepth() == PmType->
getDepth() &&
16326 TArgs->getIndex() == PmType->
getIndex()) {
16329 diag::ext_string_literal_operator_template);
16336 diag::err_literal_operator_template)
16345 if (isa<CXXMethodDecl>(FnDecl)) {
16346 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
16355 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
16374 diag::err_literal_operator_template_with_params);
16384 QualType ParamType = Param->getType().getUnqualifiedType();
16402 Diag(Param->getSourceRange().getBegin(),
16403 diag::err_literal_operator_param)
16404 << ParamType <<
"'const char *'" << Param->getSourceRange();
16409 Diag(Param->getSourceRange().getBegin(), diag::err_literal_operator_param)
16410 << ParamType << Context.
LongDoubleTy << Param->getSourceRange();
16414 Diag(Param->getSourceRange().getBegin(), diag::err_literal_operator_param)
16419 Diag(Param->getSourceRange().getBegin(),
16420 diag::err_literal_operator_invalid_param)
16421 << ParamType << Param->getSourceRange();
16430 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
16437 Diag((*Param)->getSourceRange().getBegin(),
16438 diag::err_literal_operator_param)
16439 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16446 Diag((*Param)->getSourceRange().getBegin(),
16447 diag::err_literal_operator_param)
16448 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16461 Diag((*Param)->getSourceRange().getBegin(),
16462 diag::err_literal_operator_param)
16463 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16471 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
16473 Diag((*Param)->getSourceRange().getBegin(),
16474 diag::err_literal_operator_param)
16476 << (*Param)->getSourceRange();
16480 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
16489 if (Param->hasDefaultArg()) {
16490 Diag(Param->getDefaultArgRange().getBegin(),
16491 diag::err_literal_operator_default_argument)
16492 << Param->getDefaultArgRange();
16499 if (Status != ReservedLiteralSuffixIdStatus::NotReserved &&
16500 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
16507 <<
static_cast<int>(Status)
16524 assert(Lit->
isUnevaluated() &&
"Unexpected string literal kind");
16530 else if (Lang ==
"C++")
16533 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
16553 if (getLangOpts().CPlusPlusModules && isCurrentModulePurview()) {
16554 Module *GlobalModule = PushImplicitGlobalModuleFragment(
16559 CurContext->addDecl(D);
16560 PushDeclContext(S, D);
16579 if (getLangOpts().CPlusPlusModules && getCurrentModule() &&
16580 getCurrentModule()->isImplicitGlobalModule() &&
16581 getCurrentModule()->
Parent)
16582 PopImplicitGlobalModuleFragment();
16585 return LinkageSpec;
16594 ProcessDeclAttributeList(S, ED, AttrList);
16596 CurContext->addDecl(ED);
16622 Diag(Loc, diag::err_catch_rvalue_ref);
16627 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
16633 unsigned DK = diag::err_catch_incomplete;
16635 BaseType = Ptr->getPointeeType();
16637 DK = diag::err_catch_incomplete_ptr;
16640 BaseType = Ref->getPointeeType();
16642 DK = diag::err_catch_incomplete_ref;
16644 if (!
Invalid && (Mode == 0 || !BaseType->isVoidType()) &&
16645 !BaseType->isDependentType() && RequireCompleteType(Loc, BaseType, DK))
16648 if (!
Invalid && BaseType.isWebAssemblyReferenceType()) {
16649 Diag(Loc, diag::err_wasm_reftype_tc) << 1;
16653 if (!
Invalid && Mode != 1 && BaseType->isSizelessType()) {
16654 Diag(Loc, diag::err_catch_sizeless) << (Mode == 2 ? 1 : 0) << BaseType;
16659 RequireNonAbstractType(Loc, ExDeclType,
16660 diag::err_abstract_type_in_decl,
16661 AbstractVariableType))
16671 if (T->isObjCObjectType()) {
16672 Diag(Loc, diag::err_objc_object_catch);
16674 }
else if (T->isObjCObjectPointerType()) {
16677 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
16686 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
16690 if (
const RecordType *
recordType = ExDeclType->
getAs<RecordType>()) {
16693 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
16711 Expr *opaqueValue =
16722 Expr *init = MaybeCreateExprWithCleanups(construct);
16727 FinalizeVarWithDestructor(ExDecl,
recordType);
16746 UPPC_ExceptionType)) {
16754 LookupOrdinaryName,
16755 ForVisibleRedeclaration)) {
16759 assert(!S->isDeclScope(PrevDecl));
16760 if (isDeclInScope(PrevDecl, CurContext, S)) {
16763 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
16765 }
else if (PrevDecl->isTemplateParameter())
16776 VarDecl *ExDecl = BuildExceptionDeclaration(
16783 PushOnScopeChains(ExDecl, S);
16785 CurContext->addDecl(ExDecl);
16787 ProcessDeclAttributes(S, ExDecl, D);
16793 Expr *AssertMessageExpr,
16795 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
16798 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
16799 AssertMessageExpr, RParenLoc,
false);
16809 switch (
V.getKind()) {
16810 case APValue::ValueKind::Int:
16811 if (T->isBooleanType()) {
16815 int64_t BoolValue =
V.getInt().getExtValue();
16816 assert((BoolValue == 0 || BoolValue == 1) &&
16817 "Bool type, but value is not 0 or 1");
16818 llvm::raw_svector_ostream OS(Str);
16819 OS << (BoolValue ?
"true" :
"false");
16820 }
else if (T->isCharType()) {
16822 Str.push_back(
'\'');
16823 Str.push_back(
V.getInt().getExtValue());
16824 Str.push_back(
'\'');
16826 V.getInt().toString(Str);
16830 case APValue::ValueKind::Float:
16831 V.getFloat().toString(Str);
16834 case APValue::ValueKind::LValue:
16835 if (
V.isNullPointer()) {
16836 llvm::raw_svector_ostream OS(Str);
16842 case APValue::ValueKind::ComplexFloat: {
16843 llvm::raw_svector_ostream OS(Str);
16845 V.getComplexFloatReal().toString(Str);
16847 V.getComplexFloatImag().toString(Str);
16851 case APValue::ValueKind::ComplexInt: {
16852 llvm::raw_svector_ostream OS(Str);
16854 V.getComplexIntReal().toString(Str);
16856 V.getComplexIntImag().toString(Str);
16879 if (isa<SubstNonTypeTemplateParmExpr>(E))
16883 if (
const auto *UnaryOp = dyn_cast<UnaryOperator>(E))
16888 if (isa<BinaryOperator>(E))
16897 if (
const auto *Op = dyn_cast<BinaryOperator>(E);
16898 Op && Op->getOpcode() != BO_LOr) {
16899 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
16900 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
16918 for (
unsigned I = 0; I < 2; I++) {
16919 const Expr *Side = DiagSide[I].Cond;
16924 DiagSide[I].Result.Val, Side->
getType(), DiagSide[I].ValueString);
16926 if (DiagSide[0].Print && DiagSide[1].Print) {
16927 Diag(Op->getExprLoc(), diag::note_expr_evaluates_to)
16928 << DiagSide[0].ValueString << Op->getOpcodeStr()
16929 << DiagSide[1].ValueString << Op->getSourceRange();
16935 std::string &Result,
16937 bool ErrorOnInvalidMessage) {
16939 assert(!Message->isTypeDependent() && !Message->isValueDependent() &&
16940 "can't evaluate a dependant static assert message");
16942 if (
const auto *SL = dyn_cast<StringLiteral>(Message)) {
16943 assert(SL->isUnevaluated() &&
"expected an unevaluated string");
16944 Result.assign(SL->getString().begin(), SL->getString().end());
16949 QualType T = Message->getType().getNonReferenceType();
16950 auto *RD = T->getAsCXXRecordDecl();
16952 Diag(Loc, diag::err_static_assert_invalid_message);
16956 auto FindMember = [&](StringRef
Member,
bool &Empty,
16957 bool Diag =
false) -> std::optional<LookupResult> {
16958 QualType ObjectType = Message->getType();
16960 Message->Classify(getASTContext());
16964 LookupQualifiedName(MemberLookup, RD);
16965 Empty = MemberLookup.
empty();
16970 ObjectClassification, {}, Candidates);
16975 return std::move(MemberLookup);
16980 Loc, PDiag(diag::err_static_assert_invalid_mem_fn_ret_ty)
16984 return std::nullopt;
16987 bool SizeNotFound, DataNotFound;
16988 std::optional<LookupResult> SizeMember = FindMember(
"size", SizeNotFound);
16989 std::optional<LookupResult> DataMember = FindMember(
"data", DataNotFound);
16990 if (SizeNotFound || DataNotFound) {
16991 Diag(Loc, diag::err_static_assert_missing_member_function)
16992 << ((SizeNotFound && DataNotFound) ? 2
16998 if (!SizeMember || !DataMember) {
17000 FindMember(
"size", SizeNotFound,
true);
17002 FindMember(
"data", DataNotFound,
true);
17008 Message, Message->getType(), Message->getBeginLoc(),
false,
17012 Res = BuildCallExpr(
nullptr, Res.
get(), Loc, std::nullopt, Loc,
nullptr,
17018 return TemporaryMaterializationConversion(Res.
get());
17031 SizeE.
get(), SizeT, CCEK_StaticAssertMessageSize);
17033 Diag(Loc, diag::err_static_assert_invalid_mem_fn_ret_ty) << 0;
17041 CCEK_StaticAssertMessageData);
17043 Diag(Loc, diag::err_static_assert_invalid_mem_fn_ret_ty) << 1;
17047 if (!ErrorOnInvalidMessage &&
17048 Diags.isIgnored(diag::warn_static_assert_message_constexpr, Loc))
17053 Status.Diag = &Notes;
17054 if (!Message->EvaluateCharRangeAsString(Result, EvaluatedSize.
get(),
17055 EvaluatedData.
get(), Ctx, Status) ||
17057 Diag(Message->getBeginLoc(),
17058 ErrorOnInvalidMessage ? diag::err_static_assert_message_constexpr
17059 : diag::warn_static_assert_message_constexpr);
17060 for (
const auto &
Note : Notes)
17062 return !ErrorOnInvalidMessage;
17068 Expr *AssertExpr,
Expr *AssertMessage,
17071 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
17078 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
17083 ActOnFinishFullExpr(Converted.
get(), StaticAssertLoc,
17089 AssertExpr = FullAssertExpr.
get();
17092 Expr *BaseExpr = AssertExpr;
17099 FoldKind = AllowFold;
17102 if (!Failed && VerifyIntegerConstantExpression(
17104 diag::err_static_assert_expression_is_not_constant,
17110 if (!Failed && AssertMessage &&
Cond.getBoolValue()) {
17112 EvaluateStaticAssertMessageAsString(AssertMessage, Str, Context,
17119 bool InTemplateDefinition =
17120 getLangOpts().CPlusPlus && CurContext->isDependentContext();
17122 if (!Failed && !
Cond && !InTemplateDefinition) {
17124 llvm::raw_svector_ostream Msg(MsgBuffer);
17125 bool HasMessage = AssertMessage;
17126 if (AssertMessage) {
17129 EvaluateStaticAssertMessageAsString(
17130 AssertMessage, Str, Context,
true) ||
17134 Expr *InnerCond =
nullptr;
17135 std::string InnerCondDescription;
17136 std::tie(InnerCond, InnerCondDescription) =
17137 findFailedBooleanCondition(Converted.
get());
17138 if (InnerCond && isa<ConceptSpecializationExpr>(InnerCond)) {
17145 DiagnoseUnsatisfiedConstraint(Satisfaction);
17146 }
else if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
17147 && !isa<IntegerLiteral>(InnerCond)) {
17149 diag::err_static_assert_requirement_failed)
17150 << InnerCondDescription << !HasMessage << Msg.str()
17152 DiagnoseStaticAssertDetails(InnerCond);
17156 PrintContextStack();
17161 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
17167 AssertExpr = FullAssertExpr.
get();
17171 AssertExpr, AssertMessage, RParenLoc,
17174 CurContext->addDecl(
Decl);
17184 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
17194 if (!CodeSynthesisContexts.empty()) {
17199 if (!T->isElaboratedTypeSpecifier()) {
17202 if (
const RecordType *RT = T->getAs<RecordType>()) {
17210 diag::warn_cxx98_compat_unelaborated_friend_type :
17211 diag::ext_unelaborated_friend_type)
17219 diag::warn_cxx98_compat_nonclass_type_friend :
17220 diag::ext_nonclass_type_friend)
17224 }
else if (T->getAs<EnumType>()) {
17227 diag::warn_cxx98_compat_enum_friend :
17228 diag::ext_enum_friend)
17239 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
17240 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
17257 TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec);
17259 bool IsMemberSpecialization =
false;
17263 MatchTemplateParametersToScopeSpecifier(
17264 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
17265 IsMemberSpecialization,
Invalid)) {
17266 if (TemplateParams->size() > 0) {
17271 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
17274 FriendLoc, TempParamLists.size() - 1,
17275 TempParamLists.data()).get();
17278 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
17279 << TypeWithKeyword::getTagTypeKindName(Kind) << Name;
17280 IsMemberSpecialization =
true;
17286 bool isAllExplicitSpecializations =
true;
17287 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
17288 if (TempParamLists[I]->size()) {
17289 isAllExplicitSpecializations =
false;
17299 if (isAllExplicitSpecializations) {
17301 bool Owned =
false;
17302 bool IsDependent =
false;
17303 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
Attr,
17311 false, OOK_Outside);
17315 ElaboratedTypeKeyword Keyword
17316 = TypeWithKeyword::getKeywordForTagTypeKind(Kind);
17317 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
17323 if (isa<DependentNameType>(T)) {
17337 TSI, FriendLoc, TempParamLists);
17339 CurContext->addDecl(Friend);
17343 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
17350 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
17352 ElaboratedTypeKeyword ETK = TypeWithKeyword::getKeywordForTagTypeKind(Kind);
17361 TSI, FriendLoc, TempParamLists);
17364 CurContext->addDecl(Friend);
17419 DeclaratorContext::Member);
17425 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
17442 if (TempParams.size() && !T->isElaboratedTypeSpecifier()) {
17443 Diag(Loc, diag::err_tagless_friend_type_template)
17460 if (!TempParams.empty())
17472 CurContext->addDecl(D);
17498 Diag(Loc, diag::err_unexpected_friend);
17525 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
17526 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
17527 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
17533 Scope *DCScope = S;
17535 ForExternalRedeclaration);
17543 (FunctionContainingLocalClass =
17544 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
17556 DCScope = S->getFnParent();
17559 Previous.clear(LookupLocalFriendName);
17566 DC =
Previous.getRepresentativeDecl()->getDeclContext();
17570 DC = FunctionContainingLocalClass;
17572 adjustContextForLocalExternDecl(DC);
17592 bool isTemplateId =
17610 LookupQualifiedName(
Previous, LookupDC);
17617 if (isTemplateId) {
17618 if (isa<TranslationUnitDecl>(LookupDC))
break;
17625 DCScope = getScopeForDeclContext(S, DC);
17631 DC = computeDeclContext(SS);
17632 if (!DC)
return nullptr;
17634 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
17636 LookupQualifiedName(
Previous, DC);
17640 if (DC->
Equals(CurContext))
17643 diag::warn_cxx98_compat_friend_is_member :
17644 diag::err_friend_is_member);
17680 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
17686 case UnqualifiedIdKind::IK_ConstructorTemplateId:
17687 case UnqualifiedIdKind::IK_ConstructorName:
17690 case UnqualifiedIdKind::IK_DestructorName:
17693 case UnqualifiedIdKind::IK_ConversionFunctionId:
17696 case UnqualifiedIdKind::IK_DeductionGuideName:
17699 case UnqualifiedIdKind::IK_Identifier:
17700 case UnqualifiedIdKind::IK_ImplicitSelfParam:
17701 case UnqualifiedIdKind::IK_LiteralOperatorId:
17702 case UnqualifiedIdKind::IK_OperatorFunctionId:
17703 case UnqualifiedIdKind::IK_TemplateId:
17707 if (DiagArg >= 0) {
17708 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
17719 DCScope = &FakeDCScope;
17722 bool AddToScope =
true;
17724 TemplateParams, AddToScope);
17725 if (!ND)
return nullptr;
17739 if (!CurContext->isDependentContext()) {
17742 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
17743 PushOnScopeChains(ND, EnclosingScope,
false);
17750 CurContext->addDecl(FrD);
17755 if (DC->
isRecord()) CheckFriendAccess(ND);
17759 FD = FTD->getTemplatedDecl();
17772 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
17774 diag::note_previous_declaration);
17776 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
17781 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
17788 warnOnReservedIdentifier(ND);
17794 AdjustDeclIfTemplate(Dcl);
17796 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
17798 Diag(DelLoc, diag::err_deleted_non_function);
17809 Prev->getPreviousDecl()) &&
17810 !Prev->isDefined()) {
17811 Diag(DelLoc, diag::err_deleted_decl_not_first);
17812 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
17813 Prev->isImplicit() ? diag::note_previous_implicit_declaration
17814 : diag::note_previous_declaration);
17837 Diag(DelLoc, diag::err_deleted_main);
17849 auto *FD = dyn_cast<FunctionDecl>(Dcl);
17851 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(Dcl)) {
17852 if (getDefaultedFunctionKind(FTD->getTemplatedDecl()).isComparison()) {
17853 Diag(DefaultLoc, diag::err_defaulted_comparison_template);
17858 Diag(DefaultLoc, diag::err_default_special_members)
17859 << getLangOpts().CPlusPlus20;
17869 (!FD->isDependentContext() ||
17870 (!isa<CXXConstructorDecl>(FD) &&
17872 Diag(DefaultLoc, diag::err_default_special_members)
17873 << getLangOpts().CPlusPlus20;
17880 DefKind.
asComparison() != DefaultedComparisonKind::ThreeWay) {
17882 ? diag::warn_cxx17_compat_defaulted_comparison
17883 : diag::ext_defaulted_comparison);
17886 FD->setDefaulted();
17887 FD->setExplicitlyDefaulted();
17888 FD->setDefaultLoc(DefaultLoc);
17891 if (FD->isDependentContext())
17897 FD->setWillHaveBody(
false);
17910 if (isa<CXXMethodDecl>(FD)) {
17912 if (
const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern())
17921 if (CheckExplicitlyDefaultedComparison(
nullptr, FD, DefKind.
asComparison()))
17924 DefineDefaultedComparison(DefaultLoc, FD, DefKind.
asComparison());
17928 if (CheckExplicitlyDefaultedSpecialMember(MD, DefKind.
asSpecialMember(),
17937 for (
Stmt *SubStmt : S->children()) {
17940 if (isa<ReturnStmt>(SubStmt))
17941 Self.
Diag(SubStmt->getBeginLoc(),
17942 diag::err_return_in_constructor_handler);
17943 if (!isa<Expr>(SubStmt))
17949 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
17957 switch (BodyKind) {
17958 case FnBodyKind::Delete:
17959 SetDeclDeleted(D, Loc);
17961 case FnBodyKind::Default:
17962 SetDeclDefaulted(D, Loc);
17964 case FnBodyKind::Other:
17966 "Parsed function body should be '= delete;' or '= default;'");
17976 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
17980 !NewFT->getExtParameterInfo(I).isNoEscape()) {
17982 diag::warn_overriding_method_missing_noescape);
17984 diag::note_overridden_marked_noescape);
17989 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
17990 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
17991 if ((NewCSA || OldCSA) &&
17992 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
18001 if (NewCC == OldCC)
18012 diag::err_conflicting_overriding_cc_attributes)
18038 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
18046 if (NewClassTy.
isNull()) {
18048 diag::err_different_return_type_for_overriding_virtual_function)
18063 if (
const RecordType *RT = NewClassTy->
getAs<RecordType>()) {
18064 if (!RT->isBeingDefined() &&
18065 RequireCompleteType(New->
getLocation(), NewClassTy,
18066 diag::err_covariant_return_incomplete,
18072 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
18082 if (CheckDerivedToBaseConversion(
18083 NewClassTy, OldClassTy,
18084 diag::err_covariant_return_inaccessible_base,
18085 diag::err_covariant_return_ambiguous_derived_to_base_conv,
18101 diag::err_covariant_return_type_different_qualifications)
18113 diag::err_covariant_return_type_class_type_more_qualified)
18132 Method->setRangeEnd(EndLoc);
18134 if (Method->isVirtual() || Method->getParent()->isDependentContext()) {
18139 if (!Method->isInvalidDecl())
18140 Diag(Method->getLocation(), diag::err_non_virtual_pure)
18141 << Method->getDeclName() << InitRange;
18148 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
18149 CheckPureMethod(M, ZeroLoc);
18157 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
18158 return Var->hasGlobalStorage();
18186 PushExpressionEvaluationContext(
18187 ExpressionEvaluationContext::PotentiallyEvaluated, D);
18197 PopExpressionEvaluationContext();
18200 ExitDeclaratorContext(S);
18212 "Parser allowed 'typedef' as storage class of condition decl.");
18214 Decl *Dcl = ActOnDeclarator(S, D);
18218 if (isa<FunctionDecl>(Dcl)) {
18228 if (!ExternalSource)
18232 ExternalSource->ReadUsedVTables(VTables);
18234 for (
unsigned I = 0,
N = VTables.size(); I !=
N; ++I) {
18235 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
18236 = VTablesUsed.find(VTables[I].Record);
18238 if (Pos != VTablesUsed.end()) {
18239 if (!Pos->second && VTables[I].DefinitionRequired)
18240 Pos->second =
true;
18244 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
18245 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
18248 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
18252 bool DefinitionRequired) {
18255 if (!Class->isDynamicClass() || Class->isDependentContext() ||
18256 CurContext->isDependentContext() || isUnevaluatedContext())
18260 if (TUKind !=
TU_Prefix && LangOpts.OpenMP && LangOpts.OpenMPIsTargetDevice &&
18261 !isInOpenMPDeclareTargetContext() &&
18262 !isInOpenMPTargetExecutionDirective()) {
18263 if (!DefinitionRequired)
18264 MarkVirtualMembersReferenced(Loc, Class);
18269 LoadExternalVTableUses();
18270 Class = Class->getCanonicalDecl();
18271 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
18272 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
18277 if (DefinitionRequired && !Pos.first->second) {
18278 Pos.first->second =
true;
18291 if (Class->hasUserDeclaredDestructor() && !DD->
isDefined()) {
18296 CheckDestructor(DD);
18298 MarkFunctionReferenced(Loc, Class->getDestructor());
18307 if (Class->isLocalClass())
18308 MarkVirtualMembersReferenced(Loc, Class->getDefinition());
18310 VTableUses.push_back(std::make_pair(Class, Loc));
18314 LoadExternalVTableUses();
18315 if (VTableUses.empty())
18322 bool DefinedAnything =
false;
18323 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
18332 bool DefineVTable =
true;
18338 if (KeyFunction && !KeyFunction->
hasBody()) {
18340 DefineVTable =
false;
18345 "Instantiations don't have key functions");
18347 }
else if (!KeyFunction) {
18352 bool IsExplicitInstantiationDeclaration =
18354 for (
auto *R : Class->redecls()) {
18358 IsExplicitInstantiationDeclaration =
true;
18360 IsExplicitInstantiationDeclaration =
false;
18365 if (IsExplicitInstantiationDeclaration)
18366 DefineVTable =
false;
18372 if (!DefineVTable) {
18373 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
18380 DefinedAnything =
true;
18381 MarkVirtualMembersReferenced(Loc, Class);
18383 if (VTablesUsed[Canonical])
18384 Consumer.HandleVTable(Class);
18393 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
18395 Diag(Class->getLocation(), diag::warn_weak_vtable) << Class;
18398 VTableUses.clear();
18400 return DefinedAnything;
18405 for (
const auto *I : RD->
methods())
18406 if (I->isVirtual() && !I->isPure())
18412 bool ConstexprOnly) {
18416 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
18417 E = FinalOverriders.end();
18420 OE = I->second.end();
18422 assert(OI->second.size() > 0 &&
"no final overrider");
18428 MarkFunctionReferenced(Loc, Overrider);
18436 for (
const auto &I : RD->
bases()) {
18439 if (
Base->getNumVBases() == 0)
18441 MarkVirtualMembersReferenced(Loc,
Base);
18452 CollectIvarsToConstructOrDestruct(OID, ivars);
18456 for (
unsigned i = 0; i < ivars.size(); i++) {
18458 if (Field->isInvalidDecl())
18468 InitSeq.
Perform(*
this, InitEntity, InitKind, std::nullopt);
18469 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
18480 AllToInit.push_back(
Member);
18483 if (
const RecordType *RecordTy =
18485 ->
getAs<RecordType>()) {
18488 MarkFunctionReferenced(Field->getLocation(), Destructor);
18489 CheckDestructorAccess(Field->getLocation(), Destructor,
18490 PDiag(diag::err_access_dtor_ivar)
18496 AllToInit.data(), AllToInit.size());
18515 (void)Target->
hasBody(FNTarget);
18517 cast_or_null<CXXConstructorDecl>(FNTarget));
18524 if (!Current.insert(Canonical).second)
18528 if (!Target || !Target->isDelegatingConstructor() ||
18529 Target->isInvalidDecl() || Valid.count(TCanonical)) {
18530 Valid.insert(Current.begin(), Current.end());
18533 }
else if (TCanonical == Canonical ||
Invalid.count(TCanonical) ||
18534 Current.count(TCanonical)) {
18536 if (!
Invalid.count(TCanonical)) {
18538 diag::warn_delegating_ctor_cycle)
18542 if (TCanonical != Canonical)
18543 S.
Diag(Target->getLocation(), diag::note_it_delegates_to);
18546 while (
C->getCanonicalDecl() != Canonical) {
18548 (void)
C->getTargetConstructor()->
hasBody(FNTarget);
18549 assert(FNTarget &&
"Ctor cycle through bodiless function");
18553 S.
Diag(
C->getLocation(), diag::note_which_delegates_to);
18557 Invalid.insert(Current.begin(), Current.end());
18568 for (DelegatingCtorDeclsType::iterator
18569 I = DelegatingCtorDecls.begin(ExternalSource.get()),
18570 E = DelegatingCtorDecls.end();
18574 for (
auto CI =
Invalid.begin(), CE =
Invalid.end(); CI != CE; ++CI)
18575 (*CI)->setInvalidDecl();
18584 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
18612 FindCXXThisExpr Finder(*
this);
18620 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
18624 if (
Expr *E = Method->getTrailingRequiresClause())
18625 if (!Finder.TraverseStmt(E))
18628 return checkThisInStaticMemberFunctionAttributes(Method);
18642 FindCXXThisExpr Finder(*
this);
18664 if (!Finder.TraverseType(E))
18674 FindCXXThisExpr Finder(*
this);
18677 for (
const auto *A : Method->attrs()) {
18679 Expr *Arg =
nullptr;
18681 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
18683 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
18685 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
18687 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
18689 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
18690 Arg = ETLF->getSuccessValue();
18692 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
18693 Arg = STLF->getSuccessValue();
18695 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
18696 Arg = LR->getArg();
18697 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
18699 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
18701 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
18703 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
18705 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
18708 if (Arg && !Finder.TraverseStmt(Arg))
18711 for (
unsigned I = 0,
N = Args.size(); I !=
N; ++I) {
18712 if (!Finder.TraverseStmt(Args[I]))
18726 Exceptions.clear();
18729 Exceptions.reserve(DynamicExceptions.size());
18730 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
18732 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
18737 if (!Unexpanded.empty()) {
18739 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
18747 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
18748 Exceptions.push_back(ET);
18758 "Parser should have made sure that the expression is boolean");
18759 if (IsTopLevel && DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
18774 Expr *NoexceptExpr) {
18780 MethodD = FunTmpl->getTemplatedDecl();
18789 checkExceptionSpecification(
true, EST, DynamicExceptions,
18790 DynamicExceptionRanges, NoexceptExpr, Exceptions,
18796 if (Method->isStatic())
18797 checkThisInStaticMemberFunctionExceptionSpec(Method);
18799 if (Method->isVirtual()) {
18802 CheckOverridingFunctionExceptionSpec(Method, O);
18816 Diag(DeclStart, diag::err_anonymous_property);
18824 CheckExtraCXXDefaultArguments(D);
18827 UPPC_DataMemberType)) {
18838 << getLangOpts().CPlusPlus17;
18841 diag::err_invalid_thread)
18847 ForVisibleRedeclaration);
18849 switch (
Previous.getResultKind()) {
18856 PrevDecl =
Previous.getRepresentativeDecl();
18869 PrevDecl =
nullptr;
18872 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
18873 PrevDecl =
nullptr;
18880 ProcessDeclAttributes(TUScope, NewPD, D);
18884 Record->setInvalidDecl();
18893 PushOnScopeChains(NewPD, S);
18895 Record->addDecl(NewPD);
18902 auto &Info = InventedParameterInfos.emplace_back();
18906 if (!ExplicitLists.empty()) {
18907 bool IsMemberSpecialization, IsInvalid;
18908 ExplicitParams = MatchTemplateParametersToScopeSpecifier(
18911 ExplicitLists,
false, IsMemberSpecialization, IsInvalid,
18914 if (ExplicitParams) {
18915 Info.AutoTemplateParameterDepth = ExplicitParams->
getDepth();
18916 llvm::append_range(Info.TemplateParams, *ExplicitParams);
18917 Info.NumExplicitTemplateParams = ExplicitParams->
size();
18919 Info.AutoTemplateParameterDepth = TemplateParameterDepth;
18920 Info.NumExplicitTemplateParams = 0;
18925 auto &FSI = InventedParameterInfos.back();
18926 if (FSI.TemplateParams.size() > FSI.NumExplicitTemplateParams) {
18927 if (FSI.NumExplicitTemplateParams != 0) {
18931 TemplateParameterList::Create(
18938 TemplateParameterList::Create(
18943 InventedParameterInfos.pop_back();
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool CheckLiteralType(EvalInfo &Info, const Expr *E, const LValue *This=nullptr)
Check that this core constant expression is of literal type, and if not, produce an appropriate diagn...
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static bool CheckConstraintSatisfaction(Sema &S, const NamedDecl *Template, ArrayRef< const Expr * > ConstraintExprs, llvm::SmallVectorImpl< Expr * > &Converted, const MultiLevelTemplateArgumentList &TemplateArgsLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
static Sema::SpecialMemberOverloadResult lookupCallFromSpecialMember(Sema &S, CXXRecordDecl *Class, Sema::CXXSpecialMember CSM, unsigned FieldQuals, bool ConstRHS)
Look up the special member function that would be called by a special member function for a subobject...
static void checkMoveAssignmentForRepeatedMove(Sema &S, CXXRecordDecl *Class, SourceLocation CurrentLocation)
Check if we're implicitly defining a move assignment operator for a class with virtual bases.
static void checkMethodTypeQualifiers(Sema &S, Declarator &D, unsigned DiagID)
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *Body, Sema::CheckConstexprKind Kind)
Check the body for the given constexpr function declaration only contains the permitted types of stat...
llvm::SmallPtrSet< QualType, 4 > IndirectBaseSet
Use small set to collect indirect bases.
static void checkCUDADeviceBuiltinSurfaceClassTemplate(Sema &S, CXXRecordDecl *Class)
static bool checkVectorDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const VectorType *VT)
static void SearchForReturnInStmt(Sema &Self, Stmt *S)
static void extendRight(SourceRange &R, SourceRange After)
static void DiagnoseNamespaceInlineMismatch(Sema &S, SourceLocation KeywordLoc, SourceLocation Loc, IdentifierInfo *II, bool *IsInline, NamespaceDecl *PrevNS)
Diagnose a mismatch in 'inline' qualifiers when a namespace is reopened.
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, bool ConstArg, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, Sema::InheritedConstructorInfo *ICI)
static bool RefersToRValueRef(Expr *MemRef)
static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy)
static bool isVirtualDirectBase(CXXRecordDecl *Derived, CXXRecordDecl *Base)
Determine whether a direct base class is a virtual base class.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, llvm::APSInt &Size)
#define CheckPolymorphic(Type)
static bool findCircularInheritance(const CXXRecordDecl *Class, const CXXRecordDecl *Current)
Determine whether the given class is a base class of the given class, including looking at dependent ...
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
static void CheckAbstractClassUsage(AbstractUsageInfo &Info, FunctionDecl *FD)
Check for invalid uses of an abstract type in a function declaration.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
static Expr * CastForMoving(Sema &SemaRef, Expr *E)
static void extendLeft(SourceRange &R, SourceRange Before)
static bool canPassInRegisters(Sema &S, CXXRecordDecl *D, TargetInfo::CallingConvKind CCK)
Determine whether a type is permitted to be passed or returned in registers, per C++ [class....
static void lookupOperatorsForDefaultedComparison(Sema &Self, Scope *S, UnresolvedSetImpl &Operators, OverloadedOperatorKind Op)
Perform the unqualified lookups that might be needed to form a defaulted comparison function for the ...
static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp)
Diagnose an implicit copy operation for a class which is odr-used, but which is deprecated because th...
static void AddMostOverridenMethods(const CXXMethodDecl *MD, llvm::SmallPtrSetImpl< const CXXMethodDecl * > &Methods)
Add the most overridden methods from MD to Methods.
static bool CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, CanQualType ExpectedResultType, CanQualType ExpectedFirstParamType, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag)
static bool ConvertAPValueToString(const APValue &V, QualType T, SmallVectorImpl< char > &Str)
Convert \V to a string we can present to the user in a diagnostic \T is the type of the expression th...
static DeclAccessPair findDecomposableBaseClass(Sema &S, SourceLocation Loc, const CXXRecordDecl *RD, CXXCastPath &BasePath)
Find the base class to decompose in a built-in decomposition of a class type.
static const void * GetKeyForBase(ASTContext &Context, QualType BaseType)
static Sema::ImplicitExceptionSpecification ComputeDefaultedComparisonExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD, Sema::DefaultedComparisonKind DCK)
static StmtResult buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying, unsigned Depth=0)
Builds a statement that copies/moves the given entity from From to To.
static void checkCUDADeviceBuiltinTextureClassTemplate(Sema &S, CXXRecordDecl *Class)
static void AddInitializerToDiag(const Sema::SemaDiagnosticBuilder &Diag, const CXXCtorInitializer *Previous, const CXXCtorInitializer *Current)
static bool BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, CXXBaseSpecifier *BaseSpec, bool IsInheritedVirtualBase, CXXCtorInitializer *&CXXBaseInit)
static bool checkTupleLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, VarDecl *Src, QualType DecompType, const llvm::APSInt &TupleSize)
static void NoteIndirectBases(ASTContext &Context, IndirectBaseSet &Set, const QualType &Type)
Recursively add the bases of Type. Don't add Type itself.
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc, SourceLocation &Cxx2aLoc, SourceLocation &Cxx2bLoc, Sema::CheckConstexprKind Kind)
Check the provided statement is allowed in a constexpr function definition.
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD)
static bool CheckConstexprParameterTypes(Sema &SemaRef, const FunctionDecl *FD, Sema::CheckConstexprKind Kind)
Check whether a function's parameter types are all literal types.
static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, Sema::TrivialABIHandling TAH, CXXMethodDecl **Selected)
Perform lookup for a special member of the specified kind, and determine whether it is trivial.
static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext)
Determine whether a using statement is in a context where it will be apply in all contexts.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *OrigRD)
static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class)
static bool isNonlocalVariable(const Decl *D)
Determine whether the given declaration is a global variable or static data member.
static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Is the special member function which would be selected to perform the specified operation on the spec...
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
static void findImplicitlyDeclaredEqualityComparisons(ASTContext &Ctx, CXXRecordDecl *RD, llvm::SmallVectorImpl< FunctionDecl * > &Spaceships)
Find the equality comparison functions that should be implicitly declared in a given class definition...
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void * > &IdealInits)
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
static NamespaceDecl * getNamespaceDecl(NamedDecl *D)
getNamespaceDecl - Returns the namespace a decl represents.
static bool checkArrayDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ConstantArrayType *CAT)
static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class)
static bool UsefulToPrintExpr(const Expr *E)
Some Expression types are not useful to print notes about, e.g.
static bool FindBaseInitializer(Sema &SemaRef, CXXRecordDecl *ClassDecl, QualType BaseType, const CXXBaseSpecifier *&DirectBaseSpec, const CXXBaseSpecifier *&VirtualBaseSpec)
Find the direct and/or virtual base specifiers that correspond to the given base type,...
static bool checkLiteralOperatorTemplateParameterList(Sema &SemaRef, FunctionTemplateDecl *TpDecl)
static ClassTemplateDecl * LookupStdInitializerList(Sema &S, SourceLocation Loc)
static bool CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl)
static bool ReportOverrides(Sema &S, unsigned DiagID, const CXXMethodDecl *MD, llvm::function_ref< bool(const CXXMethodDecl *)> Report)
Report an error regarding overriding, along with any relevant overridden methods.
static bool CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl)
static const void * GetKeyForMember(ASTContext &Context, CXXCtorInitializer *Member)
static std::string printTemplateArgs(const PrintingPolicy &PrintingPolicy, TemplateArgumentListInfo &Args, const TemplateParameterList *Params)
static bool CheckConstexprReturnType(Sema &SemaRef, const FunctionDecl *FD, Sema::CheckConstexprKind Kind)
Check whether a function's return type is a literal type.
static void DiagnoseBaseOrMemInitializerOrder(Sema &SemaRef, const CXXConstructorDecl *Constructor, ArrayRef< CXXCtorInitializer * > Inits)
static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD)
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T)
Determine whether the given type is an incomplete or zero-lenfgth array type.
TrivialSubobjectKind
The kind of subobject we are checking for triviality.
@ TSK_CompleteObject
The object is actually the complete object.
@ TSK_Field
The subobject is a non-static data member.
@ TSK_BaseClass
The subobject is a base class.
static bool hasOneRealArgument(MultiExprArg Args)
Determine whether the given list arguments contains exactly one "real" (non-default) argument.
static StmtResult buildMemcpyForAssignmentOp(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &ToB, const ExprBuilder &FromB)
When generating a defaulted copy or move assignment operator, if a field should be copied with __buil...
static void DefineDefaultedFunction(Sema &S, FunctionDecl *FD, SourceLocation DefaultLoc)
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, FieldDecl *Field, IndirectFieldDecl *Indirect=nullptr)
static CXXBaseSpecifier * findDirectBaseWithType(CXXRecordDecl *Derived, QualType DesiredBase, bool &AnyDependentBases)
Find the base specifier for a base class with the given type.
static bool lookupStdTypeTraitMember(Sema &S, LookupResult &TraitMemberLookup, SourceLocation Loc, StringRef Trait, TemplateArgumentListInfo &Args, unsigned DiagID)
static bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, QualType SubType, bool ConstRHS, Sema::CXXSpecialMember CSM, TrivialSubobjectKind Kind, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the special member selected for a given type would be trivial.
static StmtResult buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying)
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
static bool defaultedSpecialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, bool ConstArg, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Determine whether the specified special member function would be constexpr if it were implicitly defi...
static bool checkComplexDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ComplexType *CT)
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
static bool InitializationHasSideEffects(const FieldDecl &FD)
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
static bool checkArrayLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType)
static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, DeclStmt *DS, SourceLocation &Cxx1yLoc, Sema::CheckConstexprKind Kind)
Check the given declaration statement is legal within a constexpr function body.
static bool IsEquivalentForUsingDecl(ASTContext &Context, NamedDecl *D1, NamedDecl *D2)
Determine whether a using declaration considers the given declarations as "equivalent",...
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
static bool CheckConstexprDestructorSubobjects(Sema &SemaRef, const CXXDestructorDecl *DD, Sema::CheckConstexprKind Kind)
Determine whether a destructor cannot be constexpr due to.
static bool CheckConstexprCtorInitializer(Sema &SemaRef, const FunctionDecl *Dcl, FieldDecl *Field, llvm::SmallSet< Decl *, 16 > &Inits, bool &Diagnosed, Sema::CheckConstexprKind Kind)
Check that the given field is initialized within a constexpr constructor.
static bool isProvablyNotDerivedFrom(Sema &SemaRef, CXXRecordDecl *Record, const BaseSet &Bases)
Determines if the given class is provably not derived from all of the prospective base classes.
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt, NamedDecl *Dest)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, QualType T, Sema::CCEKind CCE, NamedDecl *Dest, APValue &PreNarrowingValue)
BuildConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter,...
static bool isInvalid(LocType Loc, bool *Invalid)
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TypeLoc interface and its subclasses.
Allows QualTypes to be sorted and hence used in maps and sets.
const NestedNameSpecifier * Specifier
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
std::pair< CXXConstructorDecl *, bool > findConstructorForBase(CXXRecordDecl *Base, CXXConstructorDecl *Ctor) const
Find the constructor to use for inherited construction of a base class, and whether that base class c...
InheritedConstructorInfo(Sema &S, SourceLocation UseLoc, ConstructorUsingShadowDecl *Shadow)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
QualType getRecordType(const RecordDecl *Decl) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
void Deallocate(void *Ptr) const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y) const
Determine whether the given template names refer to the same template.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
const clang::PrintingPolicy & getPrintingPolicy() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType getExceptionObjectType(QualType T) const
CanQualType UnsignedLongLongTy
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type.
const TargetInfo & getTargetInfo() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents an access specifier followed by colon ':'.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Wrapper for source info for arrays.
TypeLoc getElementLoc() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
Represents a C++ declaration that introduces decls from somewhere else.
unsigned shadow_size() const
Return the number of shadowed declarations associated with this using declaration.
void addShadowDecl(UsingShadowDecl *S)
shadow_iterator shadow_begin() const
void removeShadowDecl(UsingShadowDecl *S)
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static bool isCompoundAssignmentOp(Opcode Opc)
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
A binding in a decomposition declaration.
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Wrapper for source info for block pointers.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
DeclContext::lookup_iterator Decls
The declarations found inside this base class subobject.
AccessSpecifier Access
The access along this inheritance path.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
std::list< CXXBasePath >::iterator paths_iterator
Represents a base class of a C++ class.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
QualType getType() const
Retrieves the type of the base class.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
A boolean literal, per ([C++ lex.bool] Boolean literals).
CXXCatchStmt - This represents a C++ catch block.
Represents a call to a C++ constructor.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
Expr * getArg(unsigned Arg)
Return the specified argument.
bool isImmediateEscalating() const
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
ExplicitSpecifier getExplicitSpecifier()
init_iterator init_begin()
Retrieve an iterator to the first initializer.
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
Represents a C++ conversion function within a class.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Represents a C++ base or member initializer.
bool isWritten() const
Determine whether this initializer is explicitly written in the source code.
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
FieldDecl * getAnyMember() const
A use of a default initializer in a constructor or in aggregate initialization.
Represents a C++ destructor within a class.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
A mapping from each virtual member function to its set of final overriders.
Represents a call to an inherited base class constructor from an inheriting constructor.
Represents a call to a member function that may be written either with member call syntax (e....
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getMostRecentDecl()
overridden_method_range overridden_methods() const
unsigned size_overridden_methods() const
method_iterator begin_overridden_methods() const
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
Qualifiers getMethodQualifiers() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
The null pointer literal (C++11 [lex.nullptr])
A call to an overloaded operator written using operator syntax.
Represents a C++ struct/union/class.
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
friend_range friends() const
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class....
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
bool isLiteral() const
Determine whether this class is a literal type.
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
bool defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator.
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
bool hasTrivialDestructorForCall() const
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
bool defaultedDestructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
bool isLambda() const
Determine whether this class describes a lambda function object.
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12)
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
bool hasUserDeclaredCopyAssignment() const
Determine whether this class has a user-declared copy assignment operator.
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
method_range methods() const
CXXRecordDecl * getDefinition() const
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class....
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
bool hasConstexprDestructor() const
Determine whether this class has a constexpr destructor.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
bool hasTrivialCopyConstructorForCall() const
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11,...
base_class_range vbases()
base_class_iterator vbases_begin()
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
bool isAbstract() const
Determine whether this class has a pure virtual function.
bool hasVariantMembers() const
Determine whether this class has any variant members.
void setImplicitCopyConstructorIsDeleted()
Set that we attempted to declare an implicit copy constructor, but overload resolution failed so we d...
bool isDynamicClass() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
bool hasNonTrivialCopyConstructorForCall() const
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
bool hasUserDeclaredCopyConstructor() const
Determine whether this class has a user-declared copy constructor.
bool hasDefinition() const
void setImplicitCopyAssignmentIsDeleted()
Set that we attempted to declare an implicit copy assignment operator, but overload resolution failed...
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class.
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
bool hasNonTrivialDestructorForCall() const
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator,...
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class.
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
bool isInterfaceLike() const
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared.
bool hasTrivialMoveConstructorForCall() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
Represents the this expression in C++.
SourceLocation getBeginLoc() const
SourceLocation getLocation() const
CXXTryStmt - A C++ try block, including all handlers.
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
bool isCallToStdMove() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CastKind getCastKind() const
static CharSourceRange getTokenRange(SourceRange R)
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
bool isExplicitSpecialization() const
const ComparisonCategoryInfo * lookupInfoForType(QualType Ty) const
const ComparisonCategoryInfo & getInfoForType(QualType Ty) const
Return the comparison category information as specified by getCategoryForType(Ty).
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
static StringRef getCategoryString(ComparisonCategoryType Kind)
static StringRef getResultString(ComparisonCategoryResult Kind)
static std::vector< ComparisonCategoryResult > getPossibleResultsForType(ComparisonCategoryType Type)
Return the list of results which are valid for the specified comparison category type.
const CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
const ValueInfo * getValueInfo(ComparisonCategoryResult ValueKind) const
ComparisonCategoryType Kind
The Kind of the comparison category type.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
ConditionalOperator - The ?: ternary operator.
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Represents the canonical version of C arrays with a specified constant size.
const llvm::APInt & getSize() const
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared.
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
AccessSpecifier getAccess() const
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void removeDecl(Decl *D)
Removes a declaration from this context.
void addDecl(Decl *D)
Add the declaration D into this context.
decl_iterator decls_end() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Decl::Kind getDeclKind() const
DeclContext * getNonTransparentContext()
decl_iterator decls_begin() const
A reference to a declared variable, function, enum, etc.
SourceLocation getBeginLoc() const LLVM_READONLY
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
bool isImmediateEscalating() const
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool isModulePrivateSpecified() const
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
void ClearStorageClassSpecs()
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
SourceLocation getExplicitSpecLoc() const
SourceLocation getFriendSpecLoc() const
TSCS getThreadStorageClassSpec() const
ParsedAttributes & getAttributes()
SourceLocation getConstSpecLoc() const
SourceRange getExplicitSpecRange() const
Expr * getRepAsExpr() const
bool isInlineSpecified() const
SourceLocation getRestrictSpecLoc() const
bool SetTypeQual(TQ T, SourceLocation Loc)
void ClearConstexprSpec()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getAtomicSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
SourceLocation getTypeSpecTypeLoc() const
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
SourceLocation getInlineSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
SourceLocation getVolatileSpecLoc() const
FriendSpecified isFriendSpecified() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
static const TST TST_auto
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getBeginLoc() const LLVM_READONLY
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Kind
Lists the kind of concrete classes of Decl.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
@ FOK_Undeclared
A friend of a previously-undeclared entity.
@ FOK_None
Not a friend object.
bool isInExportDeclContext() const
Whether this declaration was exported in a lexical context.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isInvalidDecl() const
unsigned getIdentifierNamespace() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
void setLocalOwningModule(Module *M)
void setImplicit(bool I=true)
void setReferenced(bool R=true)
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
std::string getAsString() const
Retrieve the human-readable string for this name.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Represents a ValueDecl that came out of a declarator.
SourceLocation getBeginLoc() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
SourceLocation getIdentifierLoc() const
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool hasGroupingParens() const
void setInvalidType(bool Val=true)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isRedeclaration() const
DeclaratorContext getContext() const
const DecompositionDeclarator & getDecompositionDeclarator() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isFunctionDefinition() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
The template parameter lists that preceded the declarator.
void setInventedTemplateParameterList(TemplateParameterList *Invented)
Sets the template parameter list generated from the explicit template parameters along with any inven...
IdentifierInfo * getIdentifier() const
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
ArrayRef< Binding > bindings() const
SourceRange getSourceRange() const
SourceLocation getLSquareLoc() const
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
void setElaboratedKeywordLoc(SourceLocation Loc)
TypeLoc getNamedTypeLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
RAII object that enters a new expression evaluation context.
An instance of this object exists for each enum constant that is defined.
enumerator_range enumerators() const
EvaluatedExprVisitor - This class visits 'Expr *'s.
Store information needed for an explicit specifier.
const Expr * getExpr() const
void setKind(ExplicitSpecKind Kind)
The return type of classify().
This represents one expression.
static bool isPotentialConstantExpr(const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExpr - Return true if this function's definition might be usable in a constant exp...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
void removeInClassInitializer()
Remove the C++11 in-class initializer from this member.
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=std::nullopt)
void setUnsupportedFriend(bool Unsupported)
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
static DefaultedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups)
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ExceptionSpecificationType getExceptionSpecType() const
Gets the ExceptionSpecificationType as declared.
bool isTrivialForCall() const
bool isPure() const
Whether this virtual function is pure, i.e.
ConstexprSpecKind getConstexprKind() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
bool isImmediateFunction() const
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
SourceLocation getDefaultLoc() const
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
void setWillHaveBody(bool V=true)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
bool isDeleted() const
Whether this function has been deleted.
void setBodyContainsImmediateEscalatingExpressions(bool Set)
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
bool isImmediateEscalating() const
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
void setTrivialForCall(bool IT)
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
void setConstexprKind(ConstexprSpecKind CSK)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
DefaultedFunctionInfo * getDefaultedFunctionInfo() const
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
bool hasOneParamOrDefaultArgs() const
Determine whether this function has a single parameter, or multiple parameters where all but the firs...
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
size_t param_size() const
void setDeletedAsWritten(bool D=true)
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info)
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > exceptions() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
Declaration of a template function.
Wrapper for source info for functions.
unsigned getNumParams() const
ParmVarDecl * getParam(unsigned i) const
void setParam(unsigned i, ParmVarDecl *VD)
TypeLoc getReturnLoc() const
ExtInfo withCallingConv(CallingConv cc) const
FunctionType - C99 6.7.5.3 - Function Declarators.
CallingConv getCallConv() const
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ReservedLiteralSuffixIdStatus isReservedLiteralSuffixId() const
Determine whether this is a name reserved for future standardization or the implementation (C++ [usrl...
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
IfStmt - This represents an if/then/else.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Represents an implicitly-generated value initialization of an object of a given type.
Represents a field injected from an anonymous union/struct into the parent scope.
ArrayRef< NamedDecl * > chain() const
void setInherited(bool I)
Description of a constructor that was inherited from a base class.
ConstructorUsingShadowDecl * getShadowDecl() const
const TypeClass * getTypePtr() const
Describes an C or C++ initializer list.
unsigned getNumInits() const
const Expr * getInit(unsigned Init) const
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
Describes the capture of a variable or of this, or of a C++1y init-capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
capture_range captures() const
Retrieve this lambda's captures.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Represents a linkage specification.
void setRBraceLoc(SourceLocation L)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
LanguageIDs
Represents the language in a linkage specification.
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
An instance of this class represents the declaration of a property member.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
SourceLocation getExprLoc() const LLVM_READONLY
Wrapper for source info for member pointers.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represents a C++ namespace alias.
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
Represent a C++ namespace.
bool isInline() const
Returns true if this is an inline namespace declaration.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
void setRBraceLoc(SourceLocation L)
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ Global
The global specifier '::'. There is no stored value.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Represents an ObjC class declaration.
The basic abstraction for the target Objective-C runtime.
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
MapType::iterator iterator
MapType::const_iterator const_iterator
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
Represents a parameter to a function.
void setDefaultArg(Expr *defarg)
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
void setUninstantiatedDefaultArg(Expr *arg)
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool hasUninstantiatedDefaultArg() const
bool hasInheritedDefaultArg() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Expr * getUninstantiatedDefaultArg()
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
void setHasInheritedDefaultArg(bool I=true)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ParsedAttr - Represents a syntactic attribute.
IdentifierInfo * getPropertyDataSetter() const
IdentifierInfo * getPropertyDataGetter() const
static const ParsedAttributesView & none()
const ParsedAttr * getMSPropertyAttr() const
bool hasAttribute(ParsedAttr::Kind K) const
Wrapper for source info for pointers.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
IdentifierTable & getIdentifierTable()
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
ArrayRef< Expr * > semantics()
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType withConst() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isConstQualified() const
Determine whether this type is const-qualified.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
The collection of all-type qualifiers we support.
void addAddressSpace(LangAS space)
@ OCL_Weak
Reading or writing from this object requires a barrier call.
void removeAddressSpace()
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool hasFlexibleArrayMember() const
field_iterator field_end() const
field_range fields() const
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
@ APK_CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
@ APK_CanPassInRegs
The argument of this type can be passed directly in registers.
@ APK_CannotPassInRegs
The argument of this type cannot be passed directly in registers.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
field_iterator field_begin() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Scope - A scope is a transient data structure that is used while parsing the program.
void setEntity(DeclContext *E)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ DeclScope
This is a scope that can contain a declaration.
A RAII object to enter scope of a compound statement.
For a defaulted function, the kind of defaulted function that it is.
DefaultedComparisonKind asComparison() const
bool isSpecialMember() const
CXXSpecialMember asSpecialMember() const
bool isComparison() const
Helper class that collects exception specifications for implicitly-declared special member functions.
void CalledStmt(Stmt *S)
Integrate an invoked statement into the collected data.
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method)
Integrate another called method into the collected data.
A generic diagnostic builder for errors which may or may not be deferred.
SpecialMemberOverloadResult - The overloading result for a special member function.
CXXMethodDecl * getMethod() const
RAII object to handle the state changes required to synthesize a function body.
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
bool EvaluateStaticAssertMessageAsString(Expr *Message, std::string &Result, ASTContext &Ctx, bool ErrorOnInvalidMessage)
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
void DiagnoseAbstractType(const CXXRecordDecl *RD)
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc, const LookupResult *R=nullptr, const UsingDecl *UD=nullptr)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
void EvaluateImplicitExceptionSpec(SourceLocation Loc, FunctionDecl *FD)
Evaluate the implicit exception specification for a defaulted special member function.
ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E)
ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression found in an explicit(bool)...
void ActOnFinishCXXNonNestedClass()
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
void DiagnoseStaticAssertDetails(const Expr *E)
Try to print more useful information about a failed static_assert with expression \E.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true, bool ConsiderRequiresClauses=true)
void CheckDelegatingCtorCycles()
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD)
Check a completed declaration of an implicit special member.
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, QualType DeclInitType, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
void referenceDLLExportedClassMethods()
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions,...
bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec)
tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
FPOptionsOverride CurFPFeatureOverrides()
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType, SourceLocation Loc, const PartialDiagnostic &Diag)
Is the given member accessible for the purposes of deciding whether to define a special member functi...
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, const ParsedAttributesView &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
DiagnosticsEngine & getDiagnostics() const
ExprResult ActOnCXXThis(SourceLocation loc)
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation IdentLoc, IdentifierInfo &II, CXXScopeSpec *SS=nullptr)
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void CheckDelayedMemberExceptionSpecs()
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
ASTContext & getASTContext() const
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation, bool IsUsingIfExists)
Builds a using declaration.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer * > Initializers=std::nullopt)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl, bool IsNested)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
const LangOptions & LangOpts
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
CXXRecordDecl * getStdBadAlloc() const
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
NamedDecl * BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation NameLoc, TypeSourceInfo *EnumType, EnumDecl *ED)
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
bool CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, SourceLocation DefaultLoc)
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
void popCodeSynthesisContext()
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
ExprResult DefaultLvalueConversion(Expr *E)
bool CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMember > SpecialMemberDecl
FriendDecl * CheckFriendTypeDecl(SourceLocation LocStart, SourceLocation FriendLoc, TypeSourceInfo *TSInfo)
Perform semantic analysis of the given friend type declaration.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
void MarkVirtualBaseDestructorsReferenced(SourceLocation Location, CXXRecordDecl *ClassDecl, llvm::SmallPtrSetImpl< const RecordType * > *DirectVirtualBases=nullptr)
Mark destructors of virtual bases of this class referenced.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
unsigned ActOnReenterTemplateScope(Decl *Template, llvm::function_ref< Scope *()> EnterScope)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
bool CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *MD, DefaultedComparisonKind DCK)
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
void actOnDelayedExceptionSpecification(Decl *Method, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member function (or member function template).
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
void CheckCompleteVariableDeclaration(VarDecl *VD)
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL,...
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind)
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc)
Handle a C++ member initializer.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
DiagnosticsEngine & Diags
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
NamespaceDecl * getStdNamespace() const
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
CXXSpecialMember
Kinds of C++ special members.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
bool isAbstractType(SourceLocation Loc, QualType T)
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
void DiagnoseImmediateEscalatingReason(FunctionDecl *FD)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *Message, SourceLocation RParenLoc, bool Failed)
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef Suffix)
Determine whether a suffix is a valid ud-suffix.
StringLiteral - This represents a string literal expression, e.g.
bool isUnevaluated() const
StringRef getString() const
Represents the declaration of a struct/union/class/enum.
bool isBeingDefined() const
Return true if this decl is currently being defined.
StringRef getKindName() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
TagKind getTagKind() const
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee? This is a fundamental language change,...
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
A convenient class for passing around template argument information.
void addArgument(const TemplateArgumentLoc &Loc)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
TypeSourceInfo * getTypeSourceInfo() const
Represents a template argument.
@ Type
The template argument is a type.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ Template
A single template declaration.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
SourceRange getSourceRange() const LLVM_READONLY
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
unsigned getNumArgs() const
TemplateArgumentLoc getArgLoc(unsigned i) const
Declaration of a template type parameter.
unsigned getIndex() const
Retrieve the index of the template parameter.
unsigned getDepth() const
Retrieve the depth of the template parameter.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Declaration of an alias template.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Represents a declaration of a type.
const Type * getTypeForDecl() const
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceRange getLocalSourceRange() const
Get the local source range.
TypeLocClass getTypeLocClass() const
SourceLocation getEndLoc() const
Get the end source location.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBooleanType() const
bool isIncompleteArrayType() const
bool isUndeducedAutoType() const
bool isRValueReferenceType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isLValueReferenceType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isFunctionProtoType() const
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isFunctionType() const
bool isRealFloatingType() const
Floating point categories.
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
Simple class containing the result of Sema::CorrectTypo.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
void WillReplaceSpecifier(bool ForceReplacement)
DeclClass * getCorrectionDeclAs() const
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
static bool isIncrementDecrementOp(Opcode Op)
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a C++ unqualified-id that has been parsed.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
A set of unresolved declarations.
ArrayRef< DeclAccessPair > pairs() const
The iterator over UnresolvedSets.
A set of unresolved declarations.
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
static UnresolvedUsingIfExistsDecl * Create(ASTContext &Ctx, DeclContext *DC, SourceLocation Loc, DeclarationName Name)
Represents a dependent using declaration which was marked with typename.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
Represents a dependent using declaration which was not marked with typename.
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
DeclarationNameInfo getNameInfo() const
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Represents C++ using-directive.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Represents a C++ using-enum-declaration.
static UsingEnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, SourceLocation EnumL, SourceLocation NameL, TypeSourceInfo *EnumType)
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > UsingDecls)
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, DeclarationName Name, BaseUsingDecl *Introducer, NamedDecl *Target)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isNoDestroy(const ASTContext &) const
Is destruction of this variable entirely suppressed? If so, the variable need not have a usable destr...
bool isInlineSpecified() const
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool evaluateDestruction(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the destruction of this variable to determine if it constitutes constant destruction.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
@ TLS_Dynamic
TLS with a dynamic initializer.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
void setExceptionVariable(bool EV)
Declaration of a variable template.
Represents a GCC generic vector type.
unsigned getNumElements() const
QualType getElementType() const
Represents a C++11 virt-specifier-seq.
SourceLocation getOverrideLoc() const
SourceLocation getLastLocation() const
bool isOverrideSpecified() const
SourceLocation getFinalLoc() const
bool isFinalSpecified() const
bool isFinalSpelledSealed() const
Retains information about a function, method, or block that is currently being parsed.
bool FoundImmediateEscalatingExpression
Whether we found an immediate-escalating expression.
Defines the clang::TargetInfo interface.
const AstTypeMatcher< RecordType > recordType
T getParam(InterpFrame *Frame, unsigned Index)
bool Inc(InterpState &S, CodePtr OpPC)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
bool Zero(InterpState &S, CodePtr OpPC)
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
TypeSpecifierType
Specifies the kind of type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_ListInit
Direct list-initialization.
@ ICIS_NoInit
No in-class initializer.
@ RQ_None
No ref-qualifier was provided.
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ OK_Ordinary
An ordinary object is located at an address in memory.
std::optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
StorageClass
Storage classes.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
ComparisonCategoryType commonComparisonType(ComparisonCategoryType A, ComparisonCategoryType B)
Determine the common comparison type, as defined in C++2a [class.spaceship]p4.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
MutableArrayRef< Expr * > MultiExprArg
Language
The language for the input, used to select and validate the language standard and possible actions.
@ C
Languages that the frontend can parse and compile.
ActionResult< ParsedType > TypeResult
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
ReservedLiteralSuffixIdStatus
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
@ TNK_Concept_template
The name refers to a concept.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
bool isExternallyVisible(Linkage L)
ActionResult< Expr * > ExprResult
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
ActionResult< Stmt * > StmtResult
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
bool hasValidIntValue() const
True iff we've successfully evaluated the variable as a constant expression and extracted its integer...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
SourceLocation getEndLoc() const LLVM_READONLY
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)',...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
void freeParams()
Reset the parameter list to having zero parameters.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
One instance of this struct is used for each type in a declarator that is parsed.
enum clang::DeclaratorChunk::@210 Kind
EvalResult is a struct with detailed info about an evaluated expression.
Holds information about the various types of exception specification.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
RefQualifierKind RefQualifier
FunctionType::ExtInfo ExtInfo
Information about operator rewrites to consider when adding operator functions to a candidate set.
Describes how types, statements, expressions, and declarations should be printed.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
@ MarkingClassDllexported
We are marking a class as __dllexport.
@ InitializingStructuredBinding
We are initializing a structured binding.
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Decl * Entity
The entity that is being synthesized.
Abstract class used to diagnose incomplete types.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
Information about a template-id annotation token.
TemplateNameKind Kind
The kind of template that Template refers to.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
OpaquePtr< T > get() const